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

Populating keys with values from other documents

Subject: Populating keys with values from other documents
From: "Ashton, Andrew" <andrew_ashton@xxxxxxxxx>
Date: Tue, 29 Jun 2010 14:31:00 -0400
 Populating keys with values from other documents
I am trying to look up a value in an XML document (people.xml) based
on a @ref attribute in my primary document (source.xml).  I know that
the @ref values in source.xml will match the @xml:id values in
people.xml.  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>
        <xsl:variable name="person"
            select="document('file:///people.xml')//person[@xml:id=concat($var,
'')]"/>
        <xsl:if test="$person/residence/country">
        <span about="ont:place#{$uriRef}" property="foaf:based_near" >
            <xsl:value-of select="$person/residence/country"/>
        </span>
        </xsl:if>
</xsl:template>

But this is incredibly slow for large documents.  I have experimented
with using xsl:key, but I haven't had much.  Essentially I would like
to pre-populate the key with the values from people.xml, but I can't
quite figure out how to do that in a way that doesn't get me into a
looping scenario and/or that allows me to pass my $uriRef value to the
template that processes the key.  Can anyone explain a better
approach?

Thanks, Andy

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.