[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Writing a SELECT with each OPTION a unique value
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|