xsl-list
[Top] [All Lists]

Re: Re: RE: [xsl] Best Practice - collection() function

2008-07-07 06:44:23

Thanks for the help. I think the question sounds odd because I may have not 
been clear. You say they [keys] are built once per input document; by input 
document, do you mean supplied input file or each document in the 
collection()? I ask so I get a better understanding of whats going on when I 
use the collection() function and Keys. Right now, it works great and all my 
documents (e.g. tables, xref) are indexed.



It depends... an input document can be the main input XML in
traditional transform, a variable holding a document node, a call to
doc() etc

Have a look at this transform:

<xsl:key name="elem-by-name" match="*" use="local-name(.)"/>

<xsl:variable name="foo1">
        <foo>foo 1</foo>        
</xsl:variable>

<xsl:variable name="foo2">
        <foo>foo 2</foo>        
</xsl:variable>

<xsl:variable name="combined">
        <xsl:sequence select="($foo1, $foo2)"/>
</xsl:variable>

<xsl:template name="main">
        <xsl:value-of select="key('elem-by-name', 'foo', $foo1)"/>      
        <xsl:value-of select="key('elem-by-name', 'foo', $foo2)"/>      
        <xsl:value-of select="key('elem-by-name', 'foo', $combined)"/>  
</xsl:template>

The same key, used on three different input documents, will cause
three indexes to be built (as is my understanding).  Notice how
$combined combines two other input documents so that the key operates
across both.

-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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