あなたは、任意の整形式XMLを使用して
XSLT 1.0
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:param name="input" select="'field1,value1,field2,value2,field3,value3'"/>
<xsl:template match="/">
<root>
<xsl:call-template name="process">
<xsl:with-param name="toProcess" select="$input"/>
</xsl:call-template>
</root>
</xsl:template>
<xsl:template name="process">
<xsl:param name="toProcess"/>
<xsl:variable name="name" select="normalize-space(substring-before($toProcess,','))"/>
<xsl:variable name="value" select="normalize-space(substring-before(
concat(substring-after($toProcess,','),',')
,','))"/>
<xsl:variable name="remaining" select="substring-after(
substring-after($toProcess,',')
,',')"/>
<xsl:element name="{$name}">
<xsl:value-of select="$value"/>
</xsl:element>
<xsl:if test="string($remaining)">
<xsl:call-template name="process">
<xsl:with-param name="toProcess" select="$remaining"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
出力(...拡張機能を使用せずに、再帰的なテンプレートの呼び出しを使用することができます入力)
<root>
<field1>value1</field1>
<field2>value2</field2>
<field3>value3</field3>
</root>
それぞれXSLTバージョンを使用していますか?使用できますか?これは 'tokenize( 'field1、value1、field2、value2、field3、value3'、 '、')[position()mod 2 = 0]'を使ってXSLT 2.0で簡単に解決できます。 –
XSLT 1.0プロセッサー – Nilay
XSLT 1.0プロセッサーはどれですか? http://exslt.org/str/functions/tokenize/index.htmlをサポートしていますか? –