XML数据:
<SECTION_CONTENT_LIST_ITEM>
<NTC_NAV3>
<IMMUTABLE_ID>5786
</IMMUTABLE_ID>
<INSTRUCTION_LIST>
<INSTRUCTION_LIST_ITEM>
<NTC_NAV3INSTRUCT>
<DESCRIPTION>
<P>descrzione breve di una storia</P>
</DESCRIPTION>
</NTC_NAV3INSTRUCT>
</INSTRUCTION_LIST_ITEM>
</INSTRUCTION_LIST>
</NTC_NAV3>
</SECTION_CONTENT_LIST_ITEM>
<SECTION_CONTENT_LIST_ITEM>
<NTC_NAV3>
<IMMUTABLE_ID>5787
</IMMUTABLE_ID>
<INSTRUCTION_LIST>
<INSTRUCTION_LIST_ITEM>
<NTC_NAV3INSTRUCT>
<DESCRIPTION>
<P>descriviamo in questo capitolo qualcosa</P>
</DESCRIPTION>
</NTC_NAV3INSTRUCT>
</INSTRUCTION_LIST_ITEM>
</INSTRUCTION_LIST>
</NTC_NAV3>
</SECTION_CONTENT_LIST_ITEM>
XSL:
<xsl:for-each select="SECTION_CONTENT_LIST">
<xsl:for-each select="SECTION_CONTENT_LIST_ITEM">
<xsl:sort select="NTC_NAV3/IMMUTABLE_ID" data-type="text" order="ascending"/>
<xsl:for-each select="NTC_NAV3">
<div style="text-align:left; border-top:2px solid black;">
<span style="line-height:normal; text-align:center; ">
<xsl:value-of select=".//NTC_NAV3INSTRUCT/DESCRIPTION"/>
</span>
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
In output I would only the output :
descriviamo in questo capitolo qualcosa
this is the last description orderd by immutable_id
答案 0 :(得分:0)
您可以使用
<xsl:for-each select="SECTION_CONTENT_LIST">
<xsl:for-each select="SECTION_CONTENT_LIST_ITEM">
<xsl:sort select="NTC_NAV3/IMMUTABLE_ID" data-type="text" order="ascending"/>
<xsl:for-each select="NTC_NAV3[last()]">
<div style="text-align:left; border-top:2px solid black;">
<span style="line-height:normal; text-align:center; ">
<xsl:value-of select=".//NTC_NAV3INSTRUCT/DESCRIPTION"/>
</span>
</div>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
假设您只想处理最后一个NTC_NAV3
元素。
如果这没有帮助,那么请考虑显示XML输入的示例以及要使用XSLT创建的相应HTML输出。