私はノード「output_name」と内のテキスト値を取得したいと思い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_category」FOR-を使用して、同じタグ内に複数の要素のテキスト値を取得しますループ。
私は「my_output_name」変数にのみ正しい名前を取得することができるよ、次の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>
を使用しています。 2番目の変数は最初の値のみを取得し、 "my_output_name"変数に関しては変化しません。
私はtext()で現在のノードの値だけを得ることができることを知っています。
このコードを修正して両方の関連変数を取得する方法を教えてください。事前に
おかげで(あなたが期待される結果を投稿していなかったので)私はあなたがやりたいこと推測してい
[指定されたノードの後に兄弟ノードを検索する]が見つかりました](http://stackoverflow.com/questions/10055269/find-sibling-node-after-specified-node-is-found) – ceving
また:http://stackoverflow.com/questions/11657223/xpathget -following-sibling – ceving
またはhttp://stackoverflow.com/questions/3139402/how-to-select-following-sibling-xml-tag-using-xpath – ceving