0
私は以下のシナリオを持っています。私はネスト変換を一度も行っていないので、どのように起動するのか分かりません。私は次のサンプルを持っています。値が2桁の場合、これはすべての子孫の祖先になりました。入力xsltに複数の要素をネストする方法
:
<Items Title="Title" Icon="Icon" Description="Description">
<Item Value="01" Name="Agriculture"/>
<Item Value="011" Name="Horticulture and Fruit Growing"/>
<Item Value="0111" Name="Plant Nurseries"/>
<Item Value="011101" Name="Bulb Propagating"/>
<Item Value="0112" Name="Cut Flower and Flower Seed Growing"/>
<Item Value="011201" Name="Display Foliage Growing"/>
... ...値は
を継続している願望出力:<Items Title="Title" Icon="Icon" Description="Description">
<Item Name="Agriculture">
<Item Value="011" Name="Horticulture and Fruit Growing">
<Item Value="0111" Name="Plant Nurseries">
<Item Value="011101" Name="Bulb Propagating" />
</Item>
<Item Value="0112" Name="Cut Flower and Flower Seed Growing">
<Item Value="011201" Name="Display Foliage Growing" />
</Item>
</Item>
</Item>
...私は「
veは次のxsltを使用しました:
<xsl:template match="Items">
<Items Title="{@Title}" Icon="{@Icon}" Description="{@Description}">
<xsl:for-each select="Item">
<xsl:if test="string-length(@Value) = 2">
<Item Name="{@Name}">
<xsl:for-each select="ancestor::Items/Item">
<xsl:if test="string-length(@Value) = 3">
<Item Value="{@Value}" Name="{@Name}">
</Item>
</xsl:if>
</xsl:for-each>
</Item>
</xsl:if>
</xsl:for-each>
</Items>
</xsl:template>
しかし、これは4と6レベルのために働いていません。
今の結果は次のとおりです。
<Items Title="Title" Icon="Icon" Description="Description">
<Item Name="Agriculture">
<Item Value="011" Name="Horticulture and Fruit Growing"/>
...
ありがとうございます。それは大丈夫です。今私は関数をテストし、それから学びます。 – DanielCSD