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

Re: Parallel tree traversal


xsl tree traversal
Hunsberger, Peter wrote:


> I should have been clearer.  The nodeset function problem doesn't occur
> when I use the id/idref solution.  I'm currently evaluating a 2nd
> solution that builds the data tree as a hierarchy instead of a flat data
> structure related by id/idref.  That's when I have the nodeset issue.
> In this second case the real problem turns out to be selection of the
> child nodes to pass on to the next recursion. I had a choose block that
> looked at various metadata conditions and did things like (pseudo code):
> 
> 	variable name="data"
> 		choose
> 			when @group = true
> 				select data/*[@type = $type]
> 			otherwise
> 			  	select data/*[local-name() = $name]
> 

OK, I see. Perhaps the templates below will give you some ideas.

We have a similar situation and do what I think you want to do. My 
suggestion would be to do the work in the templates rather than trying 
to build a set of nodes and then applying templates. In the templates 
below, notice that metadata is considered when it comes to 
display/styling (hopefully the elements/attributes have meaningful names):


<xsl:template name="nav">
   <xsl:apply-templates mode="nav" select="$lsb_folder_nodeset/*"/>
</xsl:template>

<xsl:template match="s:folder | s:topic" mode="nav">
   <xsl:if test="@onnav='1' and @generate='1'">
     <xsl:variable name="_href">
       <xsl:call-template name="folder_path_builder"/>
     </xsl:variable>
     <xsl:choose>
       <xsl:when test="@expand='1'">
         <div class="normal">
           <div class="expandedFolder">
             <xsl:value-of select="@label"/>
           </div>
           <div class="expanded">
             <xsl:apply-templates mode="nav" select="s:*"/>
           </div>
         </div>
       </xsl:when>
       <xsl:when test="not(@id=$lsb_focus or 
descendant::*[@id=$lsb_focus])">
         <div class="normal">
           <a href="{$_href}">
             <xsl:value-of select="@label"/>
           </a>
         </div>
       </xsl:when>
       <xsl:otherwise>
         <div class="selected">
           <a href="{$_href}">
             <xsl:text> &#187; </xsl:text>
             <xsl:value-of select="@label"/>
           </a>
         </div>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:if>
</xsl:template>

<xsl:template match="s:page | s:content" mode="nav">
   <xsl:if test="@onnav='1' and @generate='1'">
     <xsl:variable name="id" select="@id"/>
     <xsl:variable name="_href">
       <xsl:call-template name="page_path_builder"/>
     </xsl:variable>
     <xsl:choose>
       <xsl:when test="not($id=$lsb_focus)">
         <div class="normal">
           <a href="{$_href}">
             <xsl:value-of select="@label"/>
           </a>
         </div>
       </xsl:when>
       <xsl:otherwise>
         <div class="selected">
           <a href="{$_href}">
             <xsl:text> &#187; </xsl:text>
             <xsl:value-of select="@label"/>
           </a>
         </div>
       </xsl:otherwise>
     </xsl:choose>
   </xsl:if>
</xsl:template>

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.