私はこのxmlファイルを持っています:
<A>
<B>
<elt>Add</elt>
...there are some element here
<bId>2</bId>
</B>
<B>
<elt>Add</elt>
...there are some element here
<bId>2</bId>
</B>
<B>
<elt>Add</elt>
...there are some element here
<bId>2</bId>
</B>
<B>
<elt>can</elt>
...there are some element here
<bId>3</bId>
</B>
<B>
<elt>can</elt>
...there are some element here
<bId>3</bId>
</B>
各bId要素の値を確認したいと思います。この値が前後のbId要素と同じである場合、変換後に拒否される要素bIdを除いて、ブロックBの他の要素を別のブロックに配置します。私の質問をあなたに理解させるために、ここに期待される出力があります:
<CA>
<cplx>
<spRule>
<elt>Add</elt>
...
</spRule>
<spRule>
<elt>Add</elt>
...
</spRule>
<spRule>
<elt>Add</elt>
...
</spRule>
</cplx>
<cplx>
<spRule>
<elt>can</elt>
...
</spRule>
<spRule>
<elt>can</elt>
...
</spRule>
</cplx>
</CA>
xmlファイルの要素がbIdの値でソートされていない場合でも、同じ期待される出力を取得したいと思います。私はこのxslコードを使おうとしています:
<xsl:for-each select="bId"
<CA>
<cplx>
<xsl:choose>
<xsl:when test="node()[preceding::bId]">
<xsl:copy>
<xsl:copy-of select="@*"/>
<xsl:apply-templates/>
</xsl:copy>
</xsl:when>
</cplx>
</CA>
</xsl:for-each>
しかし、それは歩きません。誰かが私を助けてくれませんか?ありがとう