输入:-
<b>
<cac:OrderLine>
<cac:LineItem>
<cbc:ID>1</cbc:ID>
<cbc:Quantity unitCode="KGM">100</cbc:Quantity>
<cbc:TotalTaxAmount currencyID="GBP">17.50</cbc:TotalTaxAmount>
<cac:Price>
<cbc:PriceAmount currencyID="GBP">100.00</cbc:PriceAmount>
<cbc:BaseQuantity unitCode="KGM">1</cbc:BaseQuantity>
</cac:Price>
</cac:LineItem>
</cac:OrderLine>
<cac:OrderLine>
<cac:LineItem>
<cbc:ID>5</cbc:ID>
<cbc:Quantity unitCode="KGM">300</cbc:Quantity>
<cbc:TotalTaxAmount currencyID="GBP">100.50</cbc:TotalTaxAmount>
<cac:Price>
<cbc:PriceAmount currencyID="GBP">2000.00</cbc:PriceAmount>
<cbc:BaseQuantity unitCode="KGM">52</cbc:BaseQuantity>
</cac:Price>
</cac:LineItem>
</cac:OrderLine>
实际上,这是输入结构,如果我们像这样应用循环
<xsl:for-each select="b/OrderLine/LineItem">它应该只选择第一个行项目,但它选择了输入中存在的所有行项目?有人能在这里解释一下xsl:for-each的功能吗?
因为循环应该应用于upto to Order本身,但上面编写的代码如何挑选输入文件中存在的所有行项目
发布于 2014-02-11 19:07:40
非常具体地回答你的问题:
1)你没有提到在哪里
<b>即将结束
2)如果您的xpath选择了所有节点,那么它肯定是文档的根节点。
3) <xsl:for-each select="b/OrderLine/LineItem">
名称本身证明了逻辑将应用于xpath所指向的"EACH“元素
https://stackoverflow.com/questions/21698664
复制相似问题