在下面的XML中,我只需要排序一個特定的分段 - attrGroupMany name =「allergenRelatedInformation」基於的子級值爲。剩下的XML應該按照這個分段進行排序。排序特定的xml節點
FDA BIG 8
因此,所有allergenSpecificationAgency具有 「FDA」 和allergenSpecificationName具有 「BIG 8」 要來 「FDA」 和 「TREE_NUTS」 之前。請建議如何在XSLT中實現這一點。謝謝。
<ns:MT_TradeItemsExport xmlns:ns="test">
<Header version="2.1">
<CreationDateTime>2017-02-09T14:19:03.566Z</CreationDateTime>
<MessageID>0072745000010_9f9cd85e-6d30-4152-a51f-d8491df45486</MessageID>
</Header>
<Payload>
<ItemRegistration>
<attr name="numberOfServingsPerPackage">4.0</attr>
</ItemRegistration>
<attrGroupMany name="organicClaim">
<row>
<attr name="organicTradeItemCode">2</attr>
<attrMany name="organicClaimAgencyCode">
<value>6</value>
</attrMany>
</row>
</attrGroupMany>
<attrGroupMany name="allergenRelatedInformation">
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AC</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AE</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AF</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AM</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AN</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AP</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">AY</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">TREE_NUTS</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">TN</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
<row>
<attr name="allergenSpecificationAgency">FDA</attr>
<attr name="allergenSpecificationName">BIG 8</attr>
<attrGroupMany name="allergen">
<row>
<attr name="allergenTypeCode">UW</attr>
<attr name="levelOfContainmentCode">FREE_FROM</attr>
</row>
</attrGroupMany>
</row>
</attrGroupMany>
</Payload>
你想的'row'子元素進行排序?你有什麼嘗試?使用'xsl:apply-templates/xsl:sort'很簡單。 –