[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Build unique nodeset when Key can't be used?

Subject: Re: Build unique nodeset when Key can't be used?
From: "Thomas B. Passin" <tpassin@xxxxxxxxxxxx>
Date: Wed, 17 Oct 2001 15:56:28 -0400
build unique
[J S Publications]>
> I have a <paragraph> element that can contain one or more <link> elements.
> Each <link> has a @type and a @id attributes. When @type='Figure' the link
> is to an image. I want to output each <paragraph>, followed by a list of
> pictures referenced in the <paragraph>.
>
> I have tried:
>
> <xsl:template match="paragraph">
>          <xsl:apply-templates mode="DoIt" />
>          <xsl:apply-templates select=link[@type='Figure']" mode="PlacePic"
/>
> </xsl:template>
>
> Which works but will repeat a reference to an image if a <link> with a
> given @id occurs more than once in the <paragraph>.
>
> How can I get a list with just one entry for each image? I can't see how
to
> you key, because key is a root-level element and so can't work with just
> the current <paragraph>.

Yes it can.  A key is declared as a top-level element, but it operates on
the context in effect when you use it.  For example, if you switch the
context to another document with

<xsl:for-each select="document('another_file')">...

then your key will index the other document.  Since <xsl:for-each> changes
the context, you could actually  have the key work with the current
paragraph.

>I have tried for-each but can't come up with a
> select that returns a 'unique' node-set.
>
Yes, you need the munchean method  or Ken Holman's new technique.

Cheers,

Tom P



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.