kl***********@googlemail.com wrote:
i get stucked on a transformation problem using XSLT. What i need is
to copy an XML Tree to an output XML without any automatic changes.
Since i used <xsl:copyor <xsl:copy-ofthere occur unwanted side
effects.
For example i just copied a xml were several namespace declarations
are present more than one time. Then
the transformation do remove the declaration at the child nodes.
Another funny automatism is - if i remove a node
which holds a namespace declaration the first child is inheriting its
declaration.
If you have e.g.
<foo xmlns="http://example.com/2008/ns1">
<bar>
<baz/>
</bar>
</foo>
then all three elements are in the namespace
http://example.com/2008/ns1. Consequently if you copy the bar element
without its foo parent then the serializer has to add a xmlns
declaration to make sure the copied element is still in its namespace.
In the XSLT/XPath 1.0 data model there are namespace nodes which are in
scope for element nodes. And xsl:copy
http://www.w3.org/TR/xslt#copying
copies these namespace nodes.
With XSLT 2.0
http://www.w3.org/TR/xslt20/#shallow-copy you can specify
whether namespaces are copied but for the namespace of the element
itself that would not prevent the copying of its namespace. If you want
to strip the namespace of an element then you can't use xsl:copy,
instead you need to create a new element e.g.
<xsl:template match="pf1:bar"
xmlns:pf1="http://example.com/2008/ns1">
<xsl:element name="{local-name()}">
<xsl:apply-templates select="@* | node()"/>
</xsl:element>
</xsl:template>
--
Martin Honnen
http://JavaScript.FAQTs.com/