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

Re: Populating keys with values from other documents

Subject: Re: Populating keys with values from other documents
From: "Ashton, Andrew" <andrew_ashton@xxxxxxxxx>
Date: Wed, 30 Jun 2010 09:32:13 -0400
Re:  Populating keys with values from other documents
On Tue, Jun 29, 2010 at 2:42 PM, David Carlisle <davidc@xxxxxxxxx> wrote:
> the code posted appeared to use @xml:id in both documents rather than @ref
> ???

Yes, sorry, I mistyped that.

>  I can do something like this:
>> <xsl:template match="name">
>>         <xsl:variable name="uriRef">
>>             <xsl:value-of
>> select="(ancestor::*[@xml:id]/@xml:id)[last()]"/>
>>         </xsl:variable>
> probably better to write that as
>  <xsl:variable name="uriRef" select="ancestor::*[@xml:id][1]/@xml:id"/.
>>         <xsl:variable name="person"
>> select="document('file:///people.xml')//person[@xml:id=concat($var,
>> '')]"/>
> in xslt2 you can write that as
>  <xsl:variable name="person"
>              select="key('p',$var,document('file:///people.xml'))"/>
> where key is defined by
> <xsl:key name="p" match="person" use="@xml:id"/>
> If you are using xslt1, you need to wrap the whole of this part of the code
> in
> <sl;for-each select="document('file:///people.xml')">
> ...
>  <xsl:variable name="person"
>              select="key('p',$var)"/>
> ...
> </xsl:for-each>

This was just what I needed, thank you very much.  I am using xslt1
for compatibility.

For comparison, the original method (i.e. making separate document()
calls for each value) took about 35 seconds to render in my webapp.
This method takes about 1 second.



Current Thread


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.
First Name
Last Name
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.