0
XSLTに値とラベルがコロン(:)と次の項目の改行で区切られたドロップダウン要素を作成しようとしています。選択オプションを作成するXSLT分割文字列
第1回私はプレーンxmlを持っています。その後、私は次のだかわからない
<root>
<text>
<item>test1 : Test 1</item>
<item>test2 : Test 2</item>
<item>test3 : Test 3</item>
</text>
</root>
:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text/text()" name="tokenize">
<xsl:param name="text" select="."/>
<xsl:param name="separator" select="'
'"/>
<xsl:choose>
<xsl:when test="not(contains($text, $separator))">
<item><xsl:value-of select="normalize-space($text)"/></item>
</xsl:when>
<xsl:otherwise>
<item>
<xsl:value-of select="normalize-space(substring-before($text, $separator))"/>
</item>
<xsl:call-template name="tokenize">
<xsl:with-param name="text" select="substring-after($text, $separator)"/>
</xsl:call-template>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
出力:(システム生成)
<root>
<item>
test1 : Test 1
test2 : Test 2
test3 : Test 3
</item>
</root>
はその後、私はそれを分割しましたか? 2番目のテンプレートを作成してhtml selectを作成することは可能ですか?
<select>
<option value="test1">Test 1</option>
<option value="test2">Test 2</option>
<option value="test3">Test 3</option>
</select>
くださいhelppppp ....: '(
うわー!それは速い!あなたは私の日を救う!名誉! – mrrsb