Subject: [xsl] xsl:key multiple select From: "Studio Codeworx" <studio@xxxxxxxxxxxxx> Date: Sun, 3 Apr 2005 20:35:42 +0200 |
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"/>&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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Problem creating XSL Attr, António Mota | Thread | [xsl] Value of <id> element not ret, aspsa |
RE: [xsl] Testing 2 XML documents f, Mukul Gandhi | Date | Re: [xsl] xsl:if, tim |
Month |