GNOME Bugzilla – Bug 318612
xsltproc should not serialize unused namespaces
Last modified: 2005-10-12 14:09:44 UTC
Assume, you want to write a transformation that removes all attributes and elements that belong to a certain namespace from a given document, you would expect that the namespace declarations, which cannot be controlled from within XSLT, will also disappear. This is not the case. It is especially not possible to use xsltproc for testing, whether a document is conforming SVG. This test requires removing all elements not from the SVG namespace and then checking against the specified DTD. This test fails, because the namespace declarations from foreign namespace are not removed. Since DTD is not aware of namespaces, the resulting document is not a valid SVG document. BTW, xmllint --nsclean also fails to remove completely unused namespaces. Other information:
The XSLT spec states that any namespace in scope of a dumped element must be issued. I have no idea what you meant by "cannot be controlled from within XSLT". You can explicitely express from XSLT 1.0 that some namespaces must not be saved unless used by the output document structure. Otherwise any in-scope namespaces are dumped because they may be used *outside* of the document structure (in text or attribute content) and the processor will not try to guess if this is the case or not. In absence of further information (reproductable test case) I think this bug is in error, though I'm very confused by your terminology. Daniel
Of cause you are right. This bug report has at least the wrong receiver. My problem cannot be generally solved with XSLT 1.0, because one can only express that some explicitely enumerated namespaces should not be saved. It is not possible to express that "none *expect* some explicitely enumerated namespaces" should be saved. Am I wrong again? Bernhard
Ok, I'm wrong again. :-) Just not <copy> a namespace node then it'll not be saved in the result document.... Sorry for the noise Bernhard
yes basically instead of using xsl:copy-of , just use xsl:element with the name , add the attributes and namespace you want and recurse, you should be able to control the namespaces emitted in this fashion Daniel