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

xsl:key multiple select

Subject: xsl:key multiple select
From: "Studio Codeworx" <studio@xxxxxxxxxxxxx>
Date: Sun, 3 Apr 2005 20:35:42 +0200
xsl key multiple
Hi,

for designing a navigation bar a loop walks through all category names
stored in a single document.
Inside Loop I'm using a key to ask a second document if the current
categoryname also exists as pagename.
if yes, the output is the categoryname formated as HREF. if no, a
dropdown-menu will created. this output works fine.

the problem
HREF needs the current page-id corresponding the category-id. id-node
"category" is the relation inside page document.

my solution
using a second key (pageid) requesting the id corresponding to node
'category' = $catid.
I think, concat() could make the criteria asking, but dont't know how to get
it work.

<xsl:variable name="dfile" select="document($datafile)"/> <xsl:key
name="pagename" match="siteinfo/pages/page/name" use="."/> <xsl:key
name="pageid" match="siteinfo/pages/page/id" use="concat(id, '+',
category)"/>


<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" select="$dfile[key('pageid', concat(id,
$catid))]"/>		

	<xsl:choose>
		<xsl:when test="$pagename">
			<xsl:if test="$pageid">
				,"<xsl:value-of select="pageid"
disable-output-escaping="yes"/><xsl:value-of select="$nbsp"
disable-output-escaping="yes"/><xsl:value-of select="$not"
disable-output-escaping="yes"/><xsl:value-of select="$nbsp"
disable-output-escaping="yes"/><xsl:value-of
select="$catname"/>","default.asp?id=<xsl:value-of
select="id"/>&amp;mnu=<xsl:value-of select="id"/>","","<xsl:value-of
select="$catname"/>",0
			</xsl:if>
		</xsl:when>
		<xsl:otherwise>					
			,"<xsl:value-of select="pageid"
disable-output-escaping="yes"/><xsl:value-of select="$nbsp"
disable-output-escaping="yes"/><xsl:value-of select="$not"
disable-output-escaping="yes"/><xsl:value-of select="$nbsp"
disable-output-escaping="yes"/><xsl:value-of
select="$catname"/><xsl:value-of select="$nbsp"
disable-output-escaping="yes"/>","show-menu=<xsl:value-of
select="$catname"/>",,"",1 		
		</xsl:otherwise>
	</xsl:choose>

</xsl:for-each>

the input

pages
- <siteinfo>
 + <data>
 + <editorsettings>
 + <pages>
    + <page>
        - <name>
            <![CDATA[SERVICE]]
           </name>
        - <category>
            <![CDATA[1]]        
       	  </category>                
     	</page>        	 
    + <page>
			.
			.
			.

categorys
- <categories>
  - <category>
    <id>
	  	<![CDATA[1]]
	  </id>
    <name>
	  	<![CDATA[SERVICE]]
	  </name>	  
		</category>		
		.
		.
		.

		  		     
would be appreciated for advises.

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

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.