私は、次のXMLがあります(x
とy
は、そのテーブル内のセルの座標である)私は最終的にHTMLテーブルに入れたいHTMLテーブルのXML項目のリストを行にソートするにはどうすればよいですか?
<items>
<item x="1" y="3"/>
<item x="2" y="4"/>
<item x="3" y="4"/>
<item x="4" y="2"/>
<item x="5" y="1"/>
</items>
をし、それが簡単に私が項目を入れたい作るために
<items>
<row y="1">
<item x="1" y="1"/>
</row>
<row y="2">
<item x="2" y="2"/>
</row>
<row y="3">
<item x="5" y="3"/>
</row>
<row y="4">
<item x="3" y="4"/>
<item x="4" y="4"/>
</row>
</items>
しかし、唯一、私は動作しませんが、また、私は、行番号と列に注釈を付けることはできませんだけでなく、思い付く変換:このような行に。
<xsl:template match="/items">
<items>
<row>
<xsl:for-each select="item">
<xsl:sort select="@y"/>
<xsl:sort select="@x"/>
<xsl:if test="preceding-sibling::item[1]/@y != @y">
<xsl:text>"</row>"</xsl:text>
<xsl:text>"<row>"</xsl:text>
</xsl:if>
<xsl:copy-of select="."/>
</xsl:for-each>
</row>
</items>
</xsl:template>
どのようにすればいいですか?
XSLT 1.0または2.0? –
Aah申し訳ありませんが、XSLT 1.0。私はそのタグを追加します。 – Fylke