0
我有这一块XMLXSLT得到相同的标签内的多个元素的文本价值
<output_list>
<output_name>name_F</output_name>
<output_category>Ferrari</output_category>
<output_name>name_P</output_name>
<output_category>Porsche</output_category>
<output_name>name_L</output_name>
<output_category>Lamborghini</output_category>
</output_list>
我想获得节点“output_name中”并在文本值“output_category”使用换循环。
我用下面的XSL
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xlink="http://www.w3.org/1999/xlink">
<xsl:output method="xml" indent="yes" encoding="utf-8" />
<xsl:template match="/" >
<xmlns:swe="http://www.opengis.net/swe/2.0"
xmlns:sml="http://www.opengis.net/sensorml/2.0">
<sml:OutputList>
<xsl:for-each select="//output_list/output_name">
<xsl:variable name="my_output_name" select="text()"/>
<xsl:variable name="my_output_category" select="//output_list/output_category"/>
<sml:output name="{$my_output_name}">
<swe:Category definition="{$my_output_category}">
</swe:Category>
</sml:output>
</xsl:for-each>
</sml:OutputList>
</xsl:stylesheet>
我能为“my_output_name”变量只能得到正确的名称。第二个变量只获得第一个值,并且它不会相对于“my_output_name”变量进行更改。
我知道用text()我只能得到当前节点的值。
你能告诉我如何解决这个代码来获得两个相关的变量?
在此先感谢
[在指定节点之后查找兄弟节点的可能重复被发现](http://stackoverflow.com/questions/10055269/find-sibling-node-after-specified-node-is-found) – ceving
另外:http://stackoverflow.com/questions/11657223/xpath-get -following-sibling – ceving
或者:http://stackoverflow.com/questions/3139402/how-to-select-following-sibling-xml-tag-using-xpath – ceving