[英]Adding namespace in root gets copied to child nodes
In below example which I found on this site, an empty xmlns="" gets copied in all child nodes.在我在此站点上找到的以下示例中,一个空的xmlns=""被复制到所有子节点中。 What can the reason be for this mistake?
这个错误的原因是什么?
My Template:我的模板:
<xsl:element xmlns="http://www.element-examples.org" name="{local-name()}">
<xsl:apply-templates select="@*|node()"/>
</xsl:element>
</xsl:template>
OUTPUT:输出:
<projectgegevens xmlns="http://www.element-examples.org">
<idopdracht **xmlns=""**>28062262</idopdracht>
<projectcode **xmlns=""**>160622</projectcode>
<projectnaam **xmlns=""**>FF0000390001</projectnaam>
<ordernummer xmlns="">M2M-2022010071</ordernummer>
<projectleider xmlns="">FF000039003</projectleider>
<opmerking xmlns=""></opmerking>
<status xmlns="">5</status>
<datumverwacht xmlns="">2022-06-29</datumverwacht>
<certificaatnummer xmlns="">2020083810</certificaatnummer>
<analysemonsters xmlns="">
We can't tell you specifically what you did wrong without seeing all your code, but the namespace declaration xmlns=""
is generated by the serializer when it finds that the result tree has an element in no namespace, whose parent is in a namespace (but with no prefix).如果没有查看所有代码,我们无法具体告诉您您做错了什么,但是当序列化程序发现结果树在 no namespace 中有一个元素,其父元素在一个命名空间中时,它会生成命名空间声明
xmlns=""
(但没有前缀)。
To find out why the child elements are in no namespace, rather than in the same namespace as their parent, you need to look at the XSLT code that creates the child elements.要找出为什么子元素不在命名空间中,而不是在与其父元素相同的命名空间中,您需要查看创建子元素的 XSLT 代码。 Note that the namespace of an element is determined entirely by the instruction that creates the element;
请注意,元素的命名空间完全由创建该元素的指令决定; it is never inherited automatically from the namespace of its parent element in the result tree (though it may be inherited from the parent element in the stylesheet).
它永远不会从结果树中其父元素的命名空间自动继承(尽管它可能是从样式表中的父元素继承的)。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.