将带有数据的最后一个节点传递到输出 XML(XSLT 问题)
Passing the last node with data to the output XML (XSLT question)
我有以下 xml:
<peci:Address>
<peci:Country>seq0</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country>seq2</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country></peci:Country>
</peci:Address>
使用以下 XSLT 行(sheet 和模板数据非常广泛,因此我决定不包含它):
xsl:value-of select="peci:Address/peci:Country"/>
获取以下数据:
<cell name="Country">seq0 seq2 </cell>
而我想:
<cell name="Country">seq2</cell>
[last()]
会产生 <cell name="Country"/>
所以这不是我要找的。
它必须是可扩展的,因为国家节点可能多于或少于 3 个,其中一些可能是空白的。我只想要它们的最后一个实例。
例如:
<peci:Address>
<peci:Country>seq0</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country>seq2</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country></peci:Country>
</peci:Address>
<peci:Address>
<peci:Country>seq3</peci:Country>
</peci:Address>
应该是:
<cell name="Country">seq3</cell>
如果您能提供一些想法,将不胜感激。
干杯!
使用谓词 (peci:Address/peci:Country[normalize-space()])[last()]
。
我有以下 xml:
<peci:Address>
<peci:Country>seq0</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country>seq2</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country></peci:Country>
</peci:Address>
使用以下 XSLT 行(sheet 和模板数据非常广泛,因此我决定不包含它):
xsl:value-of select="peci:Address/peci:Country"/>
获取以下数据:
<cell name="Country">seq0 seq2 </cell>
而我想:
<cell name="Country">seq2</cell>
[last()]
会产生 <cell name="Country"/>
所以这不是我要找的。
它必须是可扩展的,因为国家节点可能多于或少于 3 个,其中一些可能是空白的。我只想要它们的最后一个实例。
例如:
<peci:Address>
<peci:Country>seq0</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country>seq2</peci:Country>
</peci:Address>
<peci:Address>
<peci:Country></peci:Country>
</peci:Address>
<peci:Address>
<peci:Country>seq3</peci:Country>
</peci:Address>
应该是:
<cell name="Country">seq3</cell>
如果您能提供一些想法,将不胜感激。
干杯!
使用谓词 (peci:Address/peci:Country[normalize-space()])[last()]
。