0
XMLファイルを取得してXSLTで変換しようとしています。このように表示されるように、私は、変換を実行すると、私は結果をしたいと思いXSLT-1.0:カンマ区切りの値を要素値に変換します。
<root>
<TAG>10, 1, 3, 123, 4001, 34, 200, 105, 54, 0, 0, 0</TAG>
</root>
:
XMLは、私はこのようなルックスを変換しようとしています
<Field1>10</Field1>
<Field2>1</Field2>
...
<Field12>0</Field12>
、私のXSLTファイルではありません設計されたように働く。
私は、コンバータを実行するたびに、私は応答として戻ってこれを取得する:ここで
<Field_1>
<TAG>10, 1, 3, 123, 4001, 34, 200, 105, 54, 0, 0, 0</TAG>
</Field_1>
は私のXSLTファイルです:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:kml="http://www.opengis.net/kml/2.2" version="1.0">
<xsl:strip-space elements = "*"/>
<xsl:output method = "xml" indent = "yes"/>
<xsl:template match = "@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="root">
<xsl:call-template name="listItem">
<xsl:with-param name="tag" select="TAG"/>
</xsl:call-template>
</xsl:template>
<xsl:template name="listItem">
<xsl:param name="features"/>
<xsl:choose>
<xsl:when test="contains($features, ',')">
<xsl:element name="Field_{position()}">
<xsl:apply-templates select="@*|node()"/>
<xsl:value-of select="normalize-space(substring-before($features, ','))"/>
<xsl:variable name="nextValue" select="substring-after($features, ',')"/>
</xsl:element>
<xsl:if test="normalize-space($nextValue)">
<xsl:call-template name="listItem">
<xsl:with-param name="features" select="$nextValue"/>
</xsl:call-template>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<xsl:element name="Field_{position()}">
<xsl:apply-templates select="@*|node()"/>
<xsl:value-of select="$features"/>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
誰でも変換するために、私のXSLTファイルを取得する方法のための任意の提案を持っています希望の結果に私のXML?
ご協力いただきありがとうございます。
ありがとうございます!完璧に働いた。 –