【发布时间】:2017-04-09 19:26:26
【问题描述】:
<main>
<root>
<SubRoot>
<type>R</type>
<mand>N</mand>
<Section>B</Section>
</SubRoot>
<SubRoot>
<type>P</type>
<mand>Y</mand>
<Section>A</Section>
</SubRoot>
</root>
</main>
我在这个文件上有上面的 XML 文件我如何识别类型 R 或任何其他元素属于哪个节点,这里它在第一个 SubRoot 节点中。
在 xsl 文件中,如果部分的值为 A 并且此部分位于第二个 SubRoot 节点中,则我正在调用模板,如下所示, 现在我想从 when 条件中的第二个 SubRoot 节点访问其他值。我该怎么做?
<xsl:choose>
<xsl:when test="(/main/root/SubRoot[Section = 'A'])">
//Call some template
</xsl:when>
<xsl:otherwise>
//some template
</xsl:otherwise>
</xsl:choose>
我需要在 XSL 上动态验证它。因为在运行时我不知道将为 XML 生成多少节点。 如果 Section 元素的值为 A 则其内部的第二个 SubRoot 节点。在此基础上,我如何从第二个 SubRoot 节点访问其他元素的值。还请帮助告诉我建议方法的性能问题。
任何想法建议都必须受到赞赏。
【问题讨论】: