xsl-list
[Top] [All Lists]

Re: hard coded list - match?

2004-07-27 05:04:16
Hi, let me clarify things.

The following select list does not come from an XML node, that's why I said 
"hard coded". So I can't run through each value 
to append selected="true" (or selected="selected") when a certain ID is matched.

        <option value="1">News - left</option>
        <option value="2">News - right</option>
        <option value="3">Docu - left</option>
        <option value="4">Docu - right</option>
        <option value="5">Tips - left</option>
        <option value="6">Tips - right</option>
                
        <option value="7">Tickets - left</option>
        <option value="8">Tickets - right</option>
        <option value="9">Concerts - left</option>
        <option value="10">Concerts - right</option>
        <option value="11">Festivals - left</option>
        <option value="12">Festivals - right</option>           
                
        <option value="13">Fun - left</option>
        <option value="14">Fun - right</option>
        <option value="15">Games - left</option>
        <option value="16">Games - right</option>
        <option value="17">Ringtones - left</option>
        <option value="18">Ringtones - right</option>

Using XLT I retrieve an ID and I need to append selected="true" to one of the 
above options where the ID matches. I tried 
the following, but got the error: "match pattern contains a variable reference"

<xsl:variable name="nr" select="hoticon_nr"/> <!--here I retrieve the ID from 
an XML node-->
<xsl:template match="option[(_at_)value=$nr]">
        <option value="{$nr}" select="selected">
        <xsl:copy-of select="@*|node()"/>
        </option>
</xsl:template>

Grtz,

Barton


On 27 Jul 2004 at 11:40, David Carlisle wrote:

Your question isn't really very clear but I guess something like this:

a) you appear to be generating html or xhtml in which case you don't
want selected="true" as that would be invalid, you want
selected="selected".

b) take the identity transformation (from the XSLT rec, or the faq or
archives of this list) then add

<xsl:template match="option[(_at_)value=3]">
 <option select="selected">
 <xsl:copy-of select="@*|node()"/>
 </option>
</xsl:template>

David
*************************************************************************************************
The contents of this email and any attachments are confidential.
It is intended for the named recipient(s) only.
If you have received this email in error please notify the system manager or
the sender immediately. 
Do not disclose the contents to anyone nor make copies of this mail.
*************************************************************************************************



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