xsl-list
[Top] [All Lists]

[xsl] Writing a SELECT with each OPTION a unique value

2007-04-11 17:15:34
Thanks Mukel!  

For the list's viewing pleasure, I've included the latest version of the
template, using keys.
 With this version, I've reduced the # of parameters to 1, and removed
any hard-coded elements.  

<xsl:template name="selectField">
        <xsl:param name="currentNode" select="." />
        <xsl:variable name="theName" select="name($currentNode)"/>
        <xsl:variable name="theKey" select="concat('KEY_',$theName)"/>
        
        <xsl:value-of select="$theName"/>:
        <select id="SEARCH_{$theName}">
                <option selected="SELECTED" value=""></option>
                <xsl:for-each
select="$currentNode/ancestor::*/*[generate-id()=generate-id(key($theKey
,*[local-name()=$theName])[1])]">
                        <option><xsl:value-of
select="*[local-name()=$theName]" /></option>
                </xsl:for-each>
        </select>
</xsl:template>

<p>
<xsl:call-template name="selectField">
<xsl:with-param name="currentNode" select="CATALOG/CD/COUNTRY"/>
</xsl:call-template>
</p>
<p>
<xsl:call-template name="selectField">
<xsl:with-param name="currentNode" select="CATALOG/CD/COMPANY"/>
</xsl:call-template>
</p>

-Tyler Waters

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--