xsl-list
[Top] [All Lists]

runaway template application

2003-02-08 23:13:32
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="{(_at_)id}"><xsl:apply-templates select="." mode="checkedCtx"/></input>
    <xsl:value-of select="@title" />
</div>
</xsl:template>

<xsl:template match="context[(_at_)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



<Prev in Thread] Current Thread [Next in Thread>