xsl-list
[Top] [All Lists]

Re: sequence with same id values

2006-03-06 06:29:45

    <xsl:variable name="anchor" as="element()*"
   select="document('source.xml')//anchor[parent::xref]/@id"/>

    How can I get all the id values that are not unique?

It's best to say explicitly if you want an xpath2 solution (which you
do here as you are using an as= attribute so you must be using xslt2)

If you just want the distinct values, rather than a sequence of
attribute nodes with distinct values then uou can go

<xsl:variable name="anchor" as="xs:string*"
select="distinct-values(document('source.xml')//anchor[parent::xref]/@id)"/>

Your original as= attribute would generate errors as you are selecting
attribute nodes but specifying a sequence of elements.

Rather than testing on parent:: axis it's probably more natural (but
equivalent) to write this as

<xsl:variable name="anchor" as="xs:string*"
select="distinct-values(document('source.xml')//xref/anchor/@id)"/>

Depending on what you want to do with this list you may prefer to use an
xsl:for-each-group rather than use  distinct-values.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
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>
--~--



<Prev in Thread] Current Thread [Next in Thread>