0
我有喜欢的XML如下XSLT - 校验节点存在或者不使用功能
<doc>
<meta-data>
<paper-name>ABC</paper-name>
<paper-type>fi</paper-type>
</meta-data>
<section>
<figure>fig1</figure>
<figure>fig2</figure>
</section>
</doc>
我的要求是,如果<paper-type>
节点是<meta-data>
变化<figure>
节点<image>
节点可用。
因此,输出应该是什么样子,
<doc>
<meta-data>
<paper-name>ABC</paper-name>
<paper-type>fi</paper-type>
</meta-data>
<section>
<image>fig1</image>
<image>fig2</image>
</section>
</doc>
我已经写了下面的xsl做这个任务,
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<xsl:function name="abc:check-paper-type" as="xs:boolean">
<xsl:sequence select="root()//meta-data/paper-type"/>
</xsl:function>
<xsl:template match="figure[abc:check-paper-type()]">
<image>
<xsl:apply-templates/>
</image>
</xsl:template>
检查<paper-type>
节点可用内<meta-data>
我写了一个函数这里命名“签纸类型”。但不能按预期工作。
任何建议如何组织我的功能检查,<paper-type>
是否可用?
请注意,我需要通过检查<paper-type>
节点是否存在来更改大量节点。所以,使用函数检查<paper-type>
是否存在非常重要。
这是一个示例代码,我需要通过检查节点改变很多节点名称是存在或不。因此,如果我可以使用函数来检查是否可用,它将会更加有效。我对原始问题缺乏细节表示歉意。 –
sanjay
看看编辑答案是否有帮助。 –