|
Subject: [xsl] Writing a SELECT with each OPTION a unique value From: "Waters, Tyler S FOR:EX" <Tyler.Waters@xxxxxxxxx> Date: Wed, 11 Apr 2007 17:15:10 -0700 |
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
| Current Thread |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| RE: [xsl] Is there a way to avoid E, Michael Kay | Thread | [xsl] Selecting content via attribu, Ben Trafford |
| Re: [xsl] Temporary Trees and Parse, David Carlisle | Date | [xsl] Removing white space from XML, Chad Chelius |
| Month |