我有一个xml文件,在该文件上我将转换应用于特定元素,然后尝试获取所有子节点的text()忽略同一节点
<xml>
<xrefline>
<query>eligible individual</query>
in respect of a qualified dependant at any time means a person who at that time
<quote>
<para>
<n>(a)</n>
<parap>resides with the qualified dependant,</parap>
</para>
</quote>
</xrefline>
</xml>
我的xslt模板看起来像这样,我想提取所有text()并保留query元素
<xsl:template match="query" >
<xsl:apply-templates select="../text()|../node()[self::query]|../node()[not(self::query)]/text()" ></xsl:apply-templates>
</xsl:template>
我的愿望输出应该是这样的
<xml>
<xrefline>
<query>eligible individual</query>
in respect of a qualified dependant at any time means a person who at that time (a) resides with the qualified dependant,
</xrefline>
</xml>
我必须解决这个问题template match="query"
,然后再返回以获得期望的结果。在我上面的xslt中,我得到的文本位于元素引号之外,而不是quote元素的子元素之外的文本……任何帮助或提示都将非常有用。
我会写两个模板:
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* , node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="xrefline//*[not(self::query)]">
<xsl:apply-templates/>
</xsl:template>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句