define Namespace with prefix in child nodes in xslt

荒凉一梦 提交于 2019-12-13 05:55:24

问题


Is there any way to define (namespace with prefix) in child node of xml using xslt. so that my namespace apply to its decendents also, i have use

<xsl:element name="abc" namespace="{$prmPafNamespace}"> 

but it create default namespace.

when i use it like below

<xsl:element name="paf:abc" namespace="{$prmPafNamespace}">
    <xsl:element name="paf:child_abc"/>
</xsl:element>

then it gives error that 'paf' is not defined, how to solve this issue...


回答1:


You need to define the namespace on each element e.g.

<xsl:element name="paf:abc" namespace="{$prmPafNamespace}">
    <xsl:element name="paf:child_abc" namespace="{$prmPafNamespace}"/>
</xsl:element>



回答2:


You can try adding an xmlns:paf="{$prmPafNamespace}" attribute to your document/element, but I'm not sure whether it will work with a dynamic namespace URI.



来源:https://stackoverflow.com/questions/10978583/define-namespace-with-prefix-in-child-nodes-in-xslt

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!