with XSLT 2.0 using distinct-values and Saxon extensions
(saxon:evaluate) me and my colleague Nick Ardlie, just
created this code below yesterday to list all unique elements
and attributes for each element:
saxon:evaluate seems quite unnecessary here (and will be a lot more
expensive than necessary)
<xsl:template name="LIST_ATTRIBUTES">
<xsl:param name="ELEMENT"/>
<xsl:variable name="XPATH_EXPR"
select="concat('$p1//*[name()=''',$ELEMENT,''']/@*/name()')"/>
<xsl:if
test="count(distinct-values(saxon:evaluate($XPATH_EXPR,
$ROOT))) > 0">
Just do
<xsl:if test="exists($ROOT//*[name()=$ELEMENT]/@*)">
Note: count(X)>0 is equivalent to exists(X), and exists(distinct-values(X))
is equivalent to exists(X).
<xsl:for-each
select="distinct-values(saxon:evaluate($XPATH_EXPR, $ROOT))">
Here you can do
select="distinct-values($ROOT//*[name()=$ELEMENT]/@*/name())"
Michael Kay
http://www.saxonica.com/
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--