Subject: [xsl] template matching problem # 18,012 From: Steve <subsume@xxxxxxxxx> Date: Thu, 23 Aug 2007 16:05:07 -0400 |
Hello there, I created a template to auto-generate html select dropdown boxes based on some nodes. I can't get it to work precisely how I want it to. Ideally, I'd like to: <xsl:apply-templates mode="select" select="document('XML.xml')/activity/option" /> and have each option become an <option> in my select dropdown. However, as it is, instead of getting a dropdown box with 3 options (A, B, C below) I get 3 dropdownboxes. on the mode="select" template I tried to match both "*", "node()", ".", but these are off. Have I explained myself well enough? Thanks, -Steve XML=== Activities/XML.xml <activity> <option>A</option> <option>B</option> <option>C</option> </activity> XSL==== <xsl:template match="/"> <xsl:apply-templates mode="select" select="document('../../Activities/XML.xml')/activity/option"> <xsl:with-param name="id" select="'program'" /> </xsl:apply-templates> </xsl:template> <xsl:template mode="select" match="?????????"> <xsl:param name="selected" /> <xsl:param name="id" /> <xsl:param name="other" /> <xsl:param name="required" /> <xsl:param name="otherText">Other</xsl:param> <xsl:choose> <xsl:when test="$id=''"> ERROR: No id given </xsl:when> <xsl:otherwise> <select id="{$id}" name="{$id}"> <xsl:if test="$required='required'"> <xsl:attribute name="required">required</xsl:attribute> </xsl:if> <xsl:attribute name="onChange"> if(this.value=='i_Other'){ new Insertion.Before(this,"<input type='text' id='<xsl:value-of select="$id" />' name='<xsl:value-of select="$id" />' />");Element.remove(this); } </xsl:attribute> <option>Select one</option> <xsl:for-each select="../node()"> <option> <xsl:if test=".=$selected"> <xsl:attribute name="selected">selected</xsl:attribute> </xsl:if> <xsl:attribute name="value"> <xsl:choose> <xsl:when test="@key"><xsl:value-of select="@key" /></xsl:when> <xsl:otherwise><xsl:value-of select="." /></xsl:otherwise> </xsl:choose> </xsl:attribute> <xsl:value-of select="." /> </option> </xsl:for-each> <xsl:if test="$other!=''"> <option value="i_Other"><xsl:value-of select="$otherText" /></option> </xsl:if> </select> </xsl:otherwise> </xsl:choose> </xsl:template>
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Varied Results with Diffe, Atosa Khoddamhazrati | Thread | RE: [xsl] template matching problem, cknell |
Re: [xsl] Print parent text, Abel Braaksma | Date | RE: [xsl] template matching problem, cknell |
Month |