我需要幫助XSLT比較值...輸入XML,我有:XSLT從XML文檔的不同分支
<shop>
<categories>
<category categoryId="63" parentCategoryId="239">
<name>Fruit</name>
</category>
<category categoryId="62" parentCategoryId="239">
<name>Vegetable</name>
</category>
<category categoryId="60" parentCategoryId="221">
<name>Furniture</name>
</category>
...
<categories>
<products>
<product productId="3" productCode="1.05">
<name>Chair</name>
<categories>
<category>60</category>
</categories>
</product>
<product productId="21" productCode="1.59">
<name>Apple</name>
<categories>
<category>63</category>
</categories>
</product>
...
</products>
</shop>
我需要創建的產品,在那裏我有產品的名稱和列表其類別的名稱。我怎樣才能做到這一點?這不工作對我來說...
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform" >
<xsl:template match="shop">
<export>
<xsl:apply-templates select="products" />
</export>
</xsl:template>
<xsl:template match="products">
<xsl:for-each select="product">
<polozka>
<product_name>
<xsl:value-of select="name" />
</product_name>
<xsl:for-each select="/shop/categories/category">
<xsl:if test="boolean(@categoryId = /shop/products/product/categories/category)">
<category_name>
<xsl:value-of select="name" />
</category_name>
</xsl:if>
</xsl:for-each>
</polozka>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
我會很高興,如果有任何人誰可以幫我...
你能添加的樣本看起來像?謝謝! –