给定这样的 XML:
<?xml version="1.0" encoding="UTF-8"?>
<Products>
<Product someId="1EFAD9659EC">
<Identifiers>
<Identifier Id="234532423" Name="globalTradeItemNumber (GTIN)" Value="00671657621322" />
<Identifier Id="99845898" Name="Internal Supplier Part #" Value="DEL 20 10B015000" />
<Identifier Id="49348598" Name="MFG Model # (Series)" Value="DEL 20 10B015000" />
<Identifier Id="439854985" Name="MFG Part # (OEM)" Value="DEL 20 10B015000" />
<Identifier Id="2349832489" Name="UPC" Value="671657621322" />
</Identifiers>
</Product>
<Product someId="1EFAD9659EC">
<Identifiers>
<Identifier Id="234532423" Name="globalTradeItemNumber (GTIN)" Value="51651518" />
<Identifier Id="99845898" Name="Internal Supplier Part #" Value="TIM 20 10B015000" />
<Identifier Id="49348598" Name="MFG Model # (Series)" Value="TOM 20 10B015000" />
<Identifier Id="439854985" Name="MFG Part # (OEM)" Value="TAK 20 10B015000" />
<Identifier Id="2349832489" Name="UPC" Value="87468387468" />
</Identifiers>
</Product>
. . .
我想最终得到类似的东西
...
<Product upc="671657621322"/>
<Product upc="87468387468"/>
...
但我得到的是
...
<Product upc="true"/>
<Product upc="true"/>
...
我不断得到我选择的布尔答案,而不是属性的值。我在这里做错了什么愚蠢的事情?这是我正在尝试的 XSLT:
...
<xsl:template match="/">
<Output>
<xsl:apply-templates />
</Output>
</xsl:template>
<xsl:template match="Product">
<xsl:variable name="productCode" select="./Identifiers/Identifier/@Name='UPC'"/>
<Product upc="{$productCode}">
</Product>
</xsl:template>
...
谢谢。