Re: [xsl] possible to use copy-of without namespace

Subject: Re: [xsl] possible to use copy-of without namespace
From: Thomas Brand <brand@xxxxxxxxx>
Date: Wed, 08 Jan 2003 11:38:07 +0100

Hi Ken,


your solution with the template mode=".." is exactly what I was looking for, thanks indeed!!

At 03:33 08.01.2003 -0500, you wrote:
At 2003-01-08 05:03 +0100, Thomas Brand wrote:
i try to get a 1:1 copy of a tree (using xsl:copy-of) without having the xmlns attribute set in the root node of the result tree.

http://www.w3.org/TR/xslt#copy-of says "copying an element node copies the attribute nodes, namespace nodes and children of the element node as well as the element node itself"

Is there a possibility to avoid the xmlns attribute added?

Yes, by recreating each node found in the source instead of using xsl:copy-of.


But why is it important to you that an unused xmlns attribute is hanging around?

well, the guidelines for the output format are very strict. i guess one could also let them hang around maybe.. :) there is a little chance that the delivered customer gets confused about it.


Your test file is very confusing, though, because your <somechildnode> construct isn't an element ... it is inside of PCDATA. The element before is in the ans namespace and the one following isn't ... since you are using the ans namespace in the result, you will need it.

absolutely. the use of CDATA was a bloody workaround, which now has been corrected thanks to better knowledge!


i'll have to read about templates with mode attributes, never saw them.

<xsl:template mode="copy-no-ns" match="*">
  <xsl:element name="{name(.)}" namespace="{namespace-uri(.)}">
    <xsl:copy-of select="@*"/>
    <xsl:apply-templates mode="copy-no-ns"/>
  </xsl:element>
</xsl:template>


Greets from Berne, Thomas Brand


XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



Current Thread