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

runaway template application

Subject: runaway template application
From: Terence <tk.lists@xxxxxxxxxxx>
Date: Sun, 09 Feb 2003 17:13:32 +1100
template application
PROBLEM:
iterate over a list of elements, grouping them into output elements where a group is limited to a specified amount of items per group.


What I'm trying to do:
source fragment:
<filter>
 <context title="task title" id="task" checked="no" />
 <context title="frequency" id="frequency" checked="no" />
 <context title="role name" id="role" checked="yes" />
 <context title="person" id="person" checked="no" />
 <context title="system name" id="system" checked="no" />
 <context title="document keyword" id="doc_keys" checked="no" />
 <context title="document title" id="doc_title" checked="no" />
</filter>

template fragment:
<xsl:template match="/sops/filter">
<table border="0" cellspacing="0" cellpadding="4">
<tr valign="top">
<xsl:apply-templates select="context" mode="group" />
<td>
<input type="text" name="srchWd" value="<?php echo $existingWord; ?>" />
<input class="op" type="submit" name="action" value="filter" />
</td>
</tr>
</table>
</xsl:template>


<xsl:template match="context[position() mod 3 = 1]" mode="group">
<td>
    <xsl:apply-templates select="." mode="leaf"/>
    <xsl:apply-templates select="following-sibling::node()" mode="leaf"/>
</td>
</xsl:template>

<xsl:template match="context" mode="leaf">
<div class="filterContext">
<input type="radio" name="srchContext" value="{@id}"><xsl:apply-templates select="." mode="checkedCtx"/></input>
<xsl:value-of select="@title" />
</div>
</xsl:template>


<xsl:template match="context[@checked='yes']" mode="checkedCtx">
<xsl:attribute name="checked">yes</xsl:attribute>
</xsl:template>


Outcome:
The problem I'm having is with the template where mode="group"
specifically with select="following-sibling::node()"
unfortunately, the application of this template keeps going until it reaches the end of the current set of siblings. ALL I WANT IT TO DO AS APPLY THE TEMPLATE FOR THE NEXT SIBLING and then stop.


What's happening now is:
<table border="0" cellspacing="0" cellpadding="4">
<tr valign="top">
<td>
<div class="filterContext">
<input type="radio" name="srchContext" value="task">task title</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="frequency">frequency</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="role">role name</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="person">person</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="system">system name</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="doc_keys">document keyword</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="doc_title" checked>document title</div>
</td>
<td>
<div class="filterContext">
<input type="radio" name="srchContext" value="person">person</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="system">system name</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="doc_keys">document keyword</div>
<div class="filterContext">
<input type="radio" name="srchContext" value="doc_title" checked>document title</div>
</td>


<td>
<div class="filterContext">
<input type="radio" name="srchContext" value="doc_title" checked>document title</div>
</td>
<td>
<input type="text" name="srchWd" value="">
<input class="op" type="submit" name="action" value="filter">
</td>
</tr>
</table>



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



Current Thread

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
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.