Can somebody help me count the number of "nodes" or whatever you call them. Here is my XML:
<dataroot>
<Brian>1</Brian>
<Phil>2</Phil>
<Bob>3</Bob>
</dataroot>
I want to count the number of DISTINCT nodes. In other words, if Brian had a second row the total should still only be three. Is there any way to group these together and get this distinct count?
Thanks,
Phil
declare @.x xml
set @.x='<dataroot>
<Brian>1</Brian>
<Phil>2</Phil>
<Bob>3</Bob>
</dataroot>'
select @.x.query('count(distinct-values(for $a in /dataroot/* return local-name($a)))')
|||
Thanks for the reply. Question: I'm trying to use this in XSL 1.0. IS there a distinct function in there as well?
Thanks,
Phil
something like this:
<xsl:value-of select="('count(distinct-values(for $a in /dataroot/* return local-name($a)))')>
|||What's the syntax in XSLT 1.0 to do something like this:
<xsl:with-param name="numnodes" select="count(distinct-values(/dataroot/*))" />
|||Answering my own question here.
<xsl:for-each select="*[count(. | key('item-key', name(.))[1]) = 1]">
Phil
No comments:
Post a Comment