XSLTを使用してループを作成しようとしています。これにより、同じIDを持つすべてのアイテムが自動的にグループ化されますが、大文字と小文字は区別されません。残念ながら、私が解析しようとしているデータはクライアント駆動型であるため、ロードする前に変更することはできません。ここに関係なく、XML構造...
<Document>
<Row>
<Cell>ID</Cell>
</Row>
<Row>
<Cell>hi</Cell>
</Row>
<Row>
<Cell>Hi</Cell>
</Row>
<Row>
<Cell>Hello</Cell>
</Row>
<Row>
<Cell>Hello</Cell>
</Row>
<Row>
<Cell>Hola</Cell>
</Row>
</Document>
これは私が現在使用しているXSLTです...
<xsl:template match="Document">
<NewDocument xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xsl:for-each select="//Row[position() > 1]/Cell[1][not(.=preceding::Row/Cell[1])]">
<xsl:variable name="currentOrderID" select="." />
<xsl:variable name="currentOrderGroup" select="//Row[Cell[1] = $currentOrderID]" />
<MainID>
<xsl:value-of select="$currentOrderGroup[1]/Cell[1]"/>
</MainID>
<IDs>
<xsl:for-each select="$currentOrderGroup">
<id>
<xsl:value-of select="Cell[1]"/>
</id>
</xsl:for-each>
</IDs>
</xsl:for-each>
</NewDocument>
</xsl:template>
これは、CaSe SeNSiTiVeの方法で期待どおりに処理をまとめているだけです...すべてを大文字にするために、そこで変換を使用しようとしていますが、構文を正しく取得できないようです。
私がここで達成しようとしている結果はこれです:
<NewDocument>
<MainID>hi</MainID>
<IDs>
<id>hi</id>
<id>Hi</id>
</IDs>
<MainID>Hello</MainID>
<IDs>
<id>Hello</id>
<id>Hello</id>
</IDs>
<MainID>Hola</MainID>
<IDs>
<id>Hola</id>
</IDs>
</NewDocument>
私が必要としているもののために特別に何かを見つけることができないようです。ありがとう!