Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


multiple select with xsl:key

From: "Christian Schlemmer" <cs@--------.---->
To: NULL
Date: 4/3/2005 8:55:00 PM
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 do not understand the 
correct using of it.

<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 




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent