単純な(?)XSLT変換では管理できません。
入力フラット構造XMLがあります:
<root>
<attribute_a>abc</attribute_a>
<attribute_b>def</attribute_b>
<attribute_c>ghi</attribute_c>
<attribute_a>123</attribute_a>
<attribute_b>456</attribute_b>
<attribute_c>789</attribute_c>
<attribute_a>xxx</attribute_a>
<attribute_b>xxx</attribute_b>
<attribute_c>xxx</attribute_c>
</root>
次のようなXMLに変換する必要があります。
<root>
<attribute>
<attribute_a>abc</attribute_a>
<attribute_b>def</attribute_b>
<attribute_c>ghi</attribute_c>
</attribute>
<attribute>
<attribute_a>123</attribute_a>
<attribute_b>456</attribute_b>
<attribute_c>789</attribute_c>
</attribute>
<attribute>
<attribute_a>xxx</attribute_a>
<attribute_b>xxx</attribute_b>
<attribute_c>xxx</attribute_c>
</attribute>
</root>
しかし、問題はそのような変換後です:
<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<root>
<xsl:for-each select="root/attribute_a">
<attribute>
<attribute_a>
<xsl:value-of select="../attribute_a" />
</attribute_a>
<attribute_b>
<xsl:value-of select="../attribute_b" />
</attribute_b>
<attribute_c>
<xsl:value-of select="../attribute_c" />
</attribute_c>
</attribute>
</xsl:for-each>
</root>
<xsl:apply-templates />
</xsl:template>
</xsl:stylesheet>
私はこのようなものを手に入れました:
<?xml version="1.0" encoding="UTF-8"?>
<root>
<attribute>
<attribute_a>abc</attribute_a>
<attribute_b>def</attribute_b>
<attribute_c>ghi</attribute_c>
</attribute>
<attribute>
<attribute_a>abc</attribute_a>
<attribute_b>def</attribute_b>
<attribute_c>ghi</attribute_c>
</attribute>
<attribute>
<attribute_a>abc</attribute_a>
<attribute_b>def</attribute_b>
<attribute_c>ghi</attribute_c>
</attribute>
</root>
私はXSLTの経験があまりありませんが、何かアイデアはありますか?:(
よろしく、AM