Avatar of bhomass
bhomass asked on

preserve the head element attributes in w3c dom

I am using w3c dom to create html templates. I added some attribute to the <head> tag. after I apply transformer.transform(domsource, streamresult), the transformer removes the attributes, and in fact completely took over the inner tags of <head> as well.

is that any way I can tightly control the <head> tag while generating html (xml) from the w3c dom?
Java

Avatar of undefined
Last Comment
bhomass

8/22/2022 - Mon
CEHJ

>>the transformer removes the attributes, and in fact completely took over the inner tags of <head>

That shouldn't happen. You need to copy what you need to retain
ASKER
bhomass

I tested this over and over.

I can get a fragment out starting with <head>, then the head tag's attribute and inner tags are preserved.

but if I start with the <html> tag, then <head> gets the default output, discarding all the changes I made to it.

you can try this yourself.

>>That shouldn't happen. You need to copy what you need to retain
Not sure what your point is.
you think there is something I did wrong with the transformer? or the transformer is doing what it is supposed to be, and I need to manually modify the output?

I am not sure what you are saying exactly.
ASKER CERTIFIED SOLUTION
bhomass

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
Experts Exchange is like having an extremely knowledgeable team sitting and waiting for your call. Couldn't do my job half as well as I do without it!
James Murphy