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

Re: Loading an external file of index

Subject: Re: Loading an external file of index
From: Jeni Tennison <Jeni.Tennison@xxxxxxxxxxxxxxxx>
Date: Fri, 23 Jun 2000 13:45:13 +0100
xsl load files select document
Pierre,

I must say that I haven't fully got my head around how document() and key()
interact, but I'll give it my best shot.

>What does means this "for-each" as soon as I use it only to load a 
>document ?

In my head, I translate 'for-each' as 'with'.  One of the side-effects of
for-each is that it sets the current node to something that you specify, so
if you use a select expression that only contains one node, it's just like
temporarily setting the current node to that node.

>Why not only ask to load the document using an "apply-template" for 
>loading ?

Selecting a document for applying templates to is just like starting with a
new input document.  When you start processing that document, any keys that
you've defined apply to that document rather than the input document.  So,
you could alternatively do something like:

   <xsl:key name="mysetofkeys" match="/keybase/key" use="@name" />

   <!-- match on the keyref in your input document -->
   <xsl:template match="keyref">
     <!-- apply templates to the keybase of your shared document
          with a parameter giving the name of the keyref         -->
     <xsl:apply-templates select="document('../shared/shared.xml')/keybase">
       <xsl:with-param name="keyrefname" select="@name" />
     </xsl:apply-templates>
   </xsl:template>

   <!-- match on the keybase of your shared document -->
   <xsl:template match="keybase">
     <xsl:param name="keyrefname" />
     <!-- because we're within the shared document, the key()
          indexes on matching nodes within that document,
          rather than the input document.                     -->
     <b><xsl:value-of select="key('mysetofkeys', $keyrefname)/ACRONYM" /></b>
   </xsl:template>

I haven't tested this thoroughly, so it might need some fine tuning, but
I've tested the basic principal and it seems to apply.

>Does this "for-each" means that a processor needs to load and 
>reparse all keys declarations each time ?
>
>Also, I'm a little bit curious on performances : for now the document 
>database is not so heavy. But let suppose, later having a 10 000 document 
>database with something like 100 keyref in each document.
>Would an XSL transformer need to load the shared file 100 times per 
>document ? Even, looking at the syntax, would it need to load it, for each 
>keyref element, as many times as needed before finding the right key in the 
>shared document ?

I'm really not sure.  I imagine that the processor would make some
optimisations, but you'd have to ask someone who'd written one.

I'm sorry I can't be more help,

Jeni

Dr Jeni Tennison
Epistemics Ltd, Strelley Hall, Nottingham, NG8 6PE
Telephone 0115 9061301 ? Fax 0115 9061304 ? Email
jeni.tennison@xxxxxxxxxxxxxxxx



 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.