OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: [xml-dev] Parallel tree traversal

[ Lists Home | Date Index | Thread Index ]

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>




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS