0
我想一个XML文件转换到另一个XML文件,在一些情况下,添加了额外内容不提供内容添加到XML。XSLT:根据条件
我的XML看起来是这样的:
<bookstore>
<book>
<title>Book1</title>
<author>Author1</author>
<chapters>
<chapter>
<ch-name>BLABLA</ch-name>
<ch-number>1</ch-number>
</chapter>
</chapters>
</book>
<book>
<title>Book2</title>
<author>Author2</author>
<chapters>
<chapter>
<ch-name>Test</ch-name>
<ch-number>1</ch-number>
</chapter>
</chapters>
</book>
<book>
<title>Book3</title>
<author>Author3</author>
</book>
</bookstore>
现在,我要的章节元素(及其子元素)添加到书籍,它不存在,创建某种违约。
我的XSLT是这样的:
<dns:template match="book[not(exists(chapters))]">
<xsl:copy>
<xsl:apply-templates select="@*|*"/>
</xsl:copy>
<chapters>
<chapter>
<ch-name>default</ch-name>
<ch-number>default</ch-number>
</chapter>
</chapters>
</dns:template>
<xsl:template match="@* | *">
<xsl:copy>
<xsl:apply-templates select="@* | * | text()"/>
</xsl:copy>
</xsl:template>
然而,当我尝试这一个在线编辑器,没有任何更改。 dns命名空间应该支持not(exists)部分。
有什么错我的XSLT?
感谢您给予的帮助!
'dns:template'?你的意思是'xsl:template'? –
没有因为那时我不能使用没有(存在)的条款,可以吗?他们在另一个命名空间 – Tcanarchy