相关疑难解决方法(0)

在根节点中声明命名空间时,xslt脚本不起作用

下面的xslt代码不适用于下面的XML文件.但是,如果我从xml文件中的"objects"节点中删除命名空间属性,它将按预期工作.如何修复xslt代码,以便在根节点中具有命名空间属性时它将起作用?首先发布,抱歉如果格式搞砸了.谢谢

XML文件:

<objects xmlns="http://www.spicefactory.org/parsley"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" >
<object id="models" type="blah">

</object>
</objects>
Run Code Online (Sandbox Code Playgroud)

XSLT代码:

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:output method="xml" indent="no"/>

<xsl:template match="node()|@*">
     <xsl:copy>
       <xsl:apply-templates select="node()|@*"/>
     </xsl:copy>
 </xsl:template>
 <xsl:template match="object">
  <object new_attr="attr value ">
    <xsl:apply-templates select="node()|@*"/>
  </object>
 </xsl:template>
</xsl:stylesheet>
Run Code Online (Sandbox Code Playgroud)

xml xslt namespaces

2
推荐指数
1
解决办法
3357
查看次数

标签 统计

namespaces ×1

xml ×1

xslt ×1