[xsl] WG: multiple select with key

Subject: [xsl] WG: multiple select with key
From: "Studio Codeworx" <studio@xxxxxxxxxxxxx>
Date: Thu, 7 Apr 2005 22:47:59 +0200
hi david,

thx for reply.

this was the incentive for me to solve it.
---------------------------------->
The current node after $dfile[ is the root node (/) of the document
referenced by $datafile) so the first id used in your concat(id  will be the
empty string unless id is the top level element of $datafile, and will be
the whole string content of $datafile if its top level element is id. I
doubt this is what you intended, but can't suggest a fix given teh available
information.
<----------------------------------

The solution was to make a loop which selects the pageid corresponding to
the category-id relation.

<xsl:variable name="dfile" select="document($datafile)"/> <xsl:key
name="pagename" match="siteinfo/pages/page" use="name"/>

<xsl:for-each
select="document($categoryfile)//categories/category[visible!='off' and
id!=0 and member='off']">
	<xsl:variable name="catname" select="catname"/>
	<xsl:variable name="catid" select="id"/>
	<xsl:variable name="pagename" select="$dfile[key('pagename',
$catname)]"/>
			
	<xsl:variable name="pageid">
		<xsl:for-each
select="document($datafile)//siteinfo/pages/page[category=$catid]">
			<xsl:variable name="pid" select="id"/>
			<xsl:value-of select="id"/>
		</xsl:for-each>
	</xsl:variable>
		  			    
	<xsl:choose>				
		<!-- the 'test=' expression converts the returned nodeset of
xsl:key to a boolean value, therefore it can be requested for true() or
false() -->
		<xsl:when test="$pagename">
		,"<xsl:value-of select="$nbsp"/><xsl:value-of
select="$not"/><xsl:value-of select="$nbsp"/><xsl:value-of
select="$catname"/>","default.asp?id=<xsl:value-of
select="$pageid"/>&amp;mnu=<xsl:value-of
select="$pageid"/>","","<xsl:value-of select="$catname"/>",0		
		</xsl:when>
		<xsl:otherwise>					
		,"<xsl:value-of select="$nbsp"/><xsl:value-of
select="$not"/><xsl:value-of select="$nbsp"/><xsl:value-of
select="$catname"/><xsl:value-of
select="$nbsp"/>","show-menu=<xsl:value-of select="$catname"/>",,"",1

		</xsl:otherwise>
	</xsl:choose>

</xsl:for-each>

regards,
christian schlemmer

>> Codeworx <<
Vorstadt 17a
A-6800 Feldkirch
T +43 664 3044577
F +43 5522 84280
E studio@xxxxxxxxxxxxx
I www.codeworx.info 

Current Thread