Link to home
Start Free TrialLog in
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?
Avatar of CEHJ
CEHJ
Flag of United Kingdom of Great Britain and Northern Ireland image

>>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
Avatar of bhomass
bhomass

ASKER

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
Avatar of bhomass
bhomass

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial