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

RE: [xsl] XML/XSL BreadCrumb Trail


Subject: RE: [xsl] XML/XSL BreadCrumb Trail
From: Américo Albuquerque <melinor@xxxxxxx>
Date: Wed, 27 Aug 2003 22:15:13 +0100

Hi

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Bjorn Aune
> Sent: Wednesday, August 27, 2003 11:22 AM
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] XML/XSL BreadCrumb Trail 
> 
> 
> Im having problems with developing a solution for breadcrumb trail 
> (navigation path - home > page 1 > page 1.1 > etc...) with 
> xml data and xsl.
> 
> The data is stored in a sql server and is placed in a XMLDOM 
> object......objRS.Save objXML, adPersistXML. The XML data is just a 
> recordset containing all the pages for the website.
> 
> Each row in the XML contains the following attributes/values:
> - PageID
> - ParentID
> - PageTitle
> 
> <rs:data>
> <z:row PageID="1000" ParentID="0" PageTitle="Home"/>
> <z:row PageID="1001" ParentID="1000" PageTitle="Page1"/>
> <z:row PageID="1002" ParentID="1000" PageTitle="Page2"/>
> <z:row PageID="1003" ParentID="1001" PageTitle="Page1.1"/>
> ....
> ....
> </rs:data>
> 
> In the XSL(T) object i have included some ASP parameters, the 
> current PageID 
> and the parent PageID for the current page.
> 
> How should I design the XSL template to be able to get the 
> following output 
> (if the current PageID = 1003):
> 
> Home > Page1 > Page1.1
> 
> Hope to hear from you!!

Try this:

  <xsl:param name="pageID" select="1003"/>
  <xsl:key name="menu" match="z:row" use="@PageID"/>

  <xsl:template match="rs:data">
    <xsl:apply-templates select="z:row[@PageID=$pageID]"/>
  </xsl:template>

  <xsl:template match="z:row">
    <xsl:if test="not(@ParentID=0)">
      <xsl:apply-templates mode="menu" select="key('menu',@ParentID)"/>
      <xsl:text> &gt; </xsl:text>
    </xsl:if>
    <xsl:value-of select="@PageTitle"/>
  </xsl:template>

  <xsl:template match="z:row" mode="menu">
    <xsl:if test="not(@ParentID=0)">
      <xsl:apply-templates mode="menu" select="key('menu',@ParentID)"/>
      <xsl:text> &gt; </xsl:text>
    </xsl:if>
    <xsl:value-of select="@PageTitle"/>
  </xsl:template>

You'll need to bind the rs and z prefixes to the namespaces used by SQL
Server

Regards,
Americo Albuquerque


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



Current Thread
Keywords