DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT <http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22808>. ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND INSERTED IN THE BUG DATABASE.
http://nagoya.apache.org/bugzilla/show_bug.cgi?id=22808 xsl:copy doesn't copy namespace nodes [EMAIL PROTECTED] changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |REOPENED Resolution|INVALID | ------- Additional Comments From [EMAIL PROTECTED] 2003-09-04 00:05 ------- I'm reopening this but with the acknowledgement that this is getting into details of the XML spec that I'm not well versed in. >From what I understand your saying Xalan is creating valid XML output which (I believe) isn't strictly true. The XML output is well-formed but fails to validate against the schema. I'm not sure if this is appropriate or not. In particular, the elements attribute of xsl:preserve-space is a qname type so: <xsl:preserve-space elements="xhtml:*" xmlns:xsl="http://www.w3.org/1999/xhtml"/> is valid and well formed whereas: <xsl:preserve-space elements="xhtml:*"/> is well formed but not valid since the xhtml prefix is undeclared and XSLT processors will throw an error. Of course when XSLTC applies the stylesheet, it isn't aware of the schema for the document it's processing (and there's no way to strictly specify that a schema applies to an XML document anyway) So the xhtml namespace is actually referenced and the namespace declaration should be preserved. While the standard only requires well-formed output for the xml output option, the definition of xsl:copy is fairly clear on the issue: "The namespace nodes of the current node are automatically copied as well, but the attributes and children of the node are not automatically copied." So it is my belief that the implementation of xsl:copy is incorrect and the optimisation seems to be overzealous and likely to generate well-formed but invalid XML. Essentially, XSTLC has decided the namespace is not referenced and gotten it wrong - the namespace was referenced but it was in a context that XSLTC does not (and need not) check for. I guess the question then becomes, how much faster does this optimization make things? I would have imagined that blindly copying the namespace declarations would have been faster than trying to discover if they're used or not. Since the optimization makes XSLTC's xsl:copy unsuitable for use when QNAME datatypes are used in the output document that seems like a pretty heavy penalty to pay. In case others run into this bug, there are two work arounds, firstly either use copy-of instead of just copy, or specifically copy over all the namespace declaration nodes as well: <xsl:copy> <xsl:apply-templates select="@*|node()|namespace::*"/> </xsl:copy> which then allows you to selectively copy attributes or nodes if required. The other way I would imagine working around this is having something like an XSLT output option which recognizes the fact that qname datatypes may be used and preserves all namespace declarations, however this would require using non- standard extensions etc since only html, xml and text are standard output options. Is there something I'm missing in regards to the way that xsl:copy should work?
