问题
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