0
之间。这里计算节点是XML:XSLT:两个特定节点
<?xml version="1.0" encoding="UTF-8"?>
<file>
<text>
<p>
<sentence>I bought <fruit>kiwi</fruit> at the grocery store.</sentence>
<sentence>I also bought <fruit>bananas</fruit> at the store.</sentence>
<sentence base="basket">Then, I bought a basket at another store.</sentence>
<sentence>You bought <fruit>peaches</fruit> at the grocery store.</sentence>
<sentence>You also bought <fruit>apples</fruit> at the store.</sentence>
<sentence>he bought <fruit>pears</fruit> at the grocery store.</sentence>
<sentence base="basket">Then, You bought a <fruit>oranges</fruit> and a basket at another store.</sentence>
<sentence>He also bought <fruit>lemons</fruit> at the store.</sentence>
</p>
</text>
</file>
下面是需要XSLT修改:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
</xsl:template>
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates select="file/text/p/sentence[fruit]”/>
</body>
</html>
</xsl:template>
<xsl:template match="sentence[fruit]”>
<p>
<xsl:apply-templates/>
</p>
</xsl:template>
</xsl:stylesheet>
我需要<fruit>
和先前之间数句#跟着<sentence base="basket">
。例如,苹果<fruit>
</fruit>
两种<sentence>
一个<sentence base=“basket”>
(-2)和两个<sentence>
之前另一个<sentence base=“basket”>
(2)之后,而<fruit>
桔子</fruit>
是<sentence base=“basket”>
内部(-0,+ 0)。
请帮忙。下面是输出我需要:
我在杂货店买的猕猴桃(无,+2)
我还可以在商店里买香蕉(无,+ 1)
你买了桃子。在杂货店。 (-1,+3)
您还在商店买了苹果。 (-2,+ 2)
他买了梨杂货店。 (-3,+1)
然后,你在另一家商店买了一个橘子和一个篮子。 (0,0)
他还在商店买了柠檬。 (-1,无)
感谢。完善! –