1
我的XML看起來像這樣XSL分組複製問題
<page>
<orderhistory>
<order>
<ordernr>10610000000001</ordernr>
<orderrecord>
<productcategory>Something</productcategory>
</orderrecord>
<orderrecord>
<productcategory>Something</productcategory>
</orderrecord>
<orderrecord>
<productcategory>Something</productcategory>
</orderrecord>
</order>
<order>
<ordernr>10210000000001</ordernr>
<orderrecord>
<productcategory>Something</productcategory>
</orderrecord>
</order>
<order>
<ordernr>10110000000001</ordernr>
<orderrecord>
<productcategory>Something</productcategory>
</orderrecord>
</order>
<order>
<ordernr>10310000000001</ordernr>
<orderrecord>
<productcategory>Something</productcategory>
</orderrecord>
<orderrecord>
<productcategory>Forms</productcategory>
</orderrecord>
</order>
</orderhistory>
我要的是表明屬於一個訂單的所有productcategories。所以如果有一個訂單中有更多的訂單記錄,我想顯示所有類別,其次是訂單號 。
但它看起來像這樣
03-06-2009 10610000000001 something something
03-06-2009 10210000000001 something
03-06-2009 10110000000001 something
03-05-2009 10310000000001 Forms something
我從orderrecords做了XSL來分組productcategories,使重複被刪除。它似乎工作正常,但問題是,我希望它按順序分組。
<xsl:key name="orderrecord-by-productcategory" match="orderrecord" use="productcategory" />
<xsl:template match="/page/orderhistory/order">
<xsl:for-each select="orderrecord[generate-id(.) =generate-id(key('artists-by-country', productcategory)[1])]" >
<xsl:value-of select="productcategory" />
</xsl:for-each>
</xsl:template>
我的輸出看起來像現在這樣
03-06-2009 10610000000001 something
03-06-2009 10210000000001
03-06-2009 10110000000001
03-05-2009 10310000000001 Forms
,但我希望它看起來是這樣的。
03-06-2009 10610000000001 something
03-06-2009 10210000000001 something
03-06-2009 10110000000001 something
03-05-2009 10310000000001 Forms something
我該怎麼做?