例如,我有以下 xml 输入:
<Letter>
<LetterProductInfo>
<Paragraph>
<DisplayOrder>
20
</DisplayOrder>
<Text>
text abc
</Text>
</Paragraph>
</LetterProductInfo>
</Letter>
<Letter>
<LetterProductInfo>
<Paragraph>
<DisplayOrder>-10</DisplayOrder>
<Text>
text kkk
</Text>
</Paragraph>
</LetterProductInfo>
</Letter>
<Letter>
<LetterProductInfo>
<Paragraph>
<DisplayOrder>-20</DisplayOrder>
<Text>
text xyz
</Text>
</Paragraph>
</LetterProductInfo>
</Letter>
我需要帮助来编写 xsl,以便它将遍历所有字母节点并根据 DisplayOrder 的值选择文本 [我无法硬编码,因为我不知道 displayorder id 是什么,我所知道的是整数值]
就像是:
<xsl:for-each select="Letter">
<!--
missing logic so that xsl:value-of select="?" will print
1. test xyz - because its DisplayOrderId is -20
2. text kkk - because its DisplayOrderId is -10
3. text abc - because its DisplayOrderId is 20
-->
</xsl:for-each>
谢谢。