[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: Re: Re: Re: RE: [xsl] Best Practice - collection() function
From: <philip.vallone@xxxxxxxxxxx>
Date: Mon, 07 Jul 2008 09:20:05 -0500 (CDT)

Hi Andrew,

Thank you for the help and guidance.

Regards,

Phil

From: Andrew Welch <andrew.j.welch@xxxxxxxxx>
Date: 2008/07/07 Mon AM 08:44:01 CDT
To: philip.vallone@xxxxxxxxxxx
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: Re: RE: [xsl] Best Practice - collection() function

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


Current Thread
Keywords
xml