具有这样的 XML 结构:
<ContextDoc>
<PurchaseOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<OrderForms>
<OrderForm>
<Shipments>
<Shipment>
...
<ShippingMethodId>17995798-a2cc-43ad-81e8-bb932f6827e4</ShippingMethodId>
...
</Shipment>
<Shipment>
...
<ShippingMethodId>11223344-a2cc-11bc-25a7-aa345f6827e6</ShippingMethodId>
...
</Shipment>
</Shipments>
<LineItems>
<LineItem>
...
<ShippingMethodId>17995798-a2cc-43ad-81e8-bb932f6827e4</ShippingMethodId>
...
</LineItem>
<LineItem>
...
<ShippingMethodId>17995798-a2cc-43ad-81e8-bb932f6827e4</ShippingMethodId>
...
</LineItem>
<LineItem>
...
<ShippingMethodId>11223344-a2cc-11bc-25a7-aa345f6827e6</ShippingMethodId>
...
</LineItem>
</LineItems>
</OrderForm>
</OrderForms>
</PurchaseOrder>
</ContextDoc>
从与每个 Shipment 节点匹配的模板中,我想用当前的 ShippingMethodId 循环 LineItems。像这样:
<xsl:template match="Shipment">
<xsl:for-each select="//LineItems/LineItem[ShippingMethodId=./ShippingMethodId]">
<xsl:call-template name="LineItem">
</xsl:call-template>
</xsl:for-each>
</xsl:Template>
但这给了我每个 Shipment 下的所有 LineItems。为特定 LineItem 节点调用模板的正确方法是什么?