1
我有一個xsl文檔,其中包含一些屬性,我必須通過名稱來計算此文檔中唯一屬性的數量。使用xslt計算所有不同的屬性
例如XML:
<Collection>
<item>
<Id attr1="value1">123</Id>
<property>u1</property>
</item>
<item>
<Id>1234</Id>
<property>u2</property>
</item>
<item attr1="value11">
<Id>12345</Id>
<property>u3</property>
</item>
<item attr2="value2">
<Id>123456</Id>
<property attr3="value3">u4</property>
</item>
</Collection>
有4個屬性,但attR1位被複制,所以答案是3 我有興趣使用XSLT 1.0做到這一點。
現在我有這樣的事情,但不能提出反
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="node" match="@*" use="local-name()"/>
<xsl:template match="/">
<xsl:for-each select="//@*">
<xsl:variable name="name" select="local-name()"/>
<xsl:if test="generate-id(.) = generate-id(key('node', $name))">
<!-- increment counter? -->
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
感謝
謝謝,這真是我試圖做的! – unr 2012-03-10 09:22:03