1
나는 명백한 것을 놓치고있는 것처럼 느껴진다. 그러나 XSLT 1.0 키가 나에게 효과적이지 않은 이유를 알아낼 수 없다.XSLT 키가 예상대로 작동하지 않는 이유는 무엇입니까?
원하는 출력은 "샘플 브랜드"입니다 (아래 XSLT 주석 참조). 아무 것도 출력되지 않습니다.
for-each
일부 더미 출력과 함께 함수를 사용할 때 아무 것도 출력되지 않으며 (0 키가있는 것처럼 보입니다) 키를 생성하지 못했음을 나타냅니다. 항목). 그러나 나는 이것에 관해 확실하지 않다.
XML :
<data>
<products-by-instances>
<entry id="1975">
<name>Sample Name</name>
<brand>
<item id="1970">Sample Brand</item>
</brand>
<instances>
<item id="1972">MILT501</item>
<item id="1974">MILT502</item>
</instances>
</entry>
</products-by-instances>
<shopping-cart items="2" total="35">
<item id="1972" num="1" sum="5" />
<item id="1974" num="3" sum="30" />
</shopping-cart>
</data>
XSLT :
<xsl:value-of select="key('products-by-instance-id', @id)/brand/item"/>
키 현재 작업 : 지금은 따옴표로 키 이름을 넣어 무시 나에게 지적되어있어
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="products-by-instance-id" match="/data/products-by-instances/entry" use="instances/item/@id"/>
<!-- other templates redacted for brevity; the below template is being applied -->
<xsl:template match="/data/shopping-cart/item">
<xsl:value-of select="key(products-by-instance-id, @id)/brand/item"/>
<!-- desired output is "Sample Brand" -->
</xsl:template>