Re: [xsl] Newbie Question with @value

Subject: Re: [xsl] Newbie Question with @value
From: "Jon Gorman" <jonathan.gorman@xxxxxxxxx>
Date: Tue, 28 Mar 2006 14:11:03 -0600
>                                                 <xsl:if
test="@type='radio'">
>                                                         <asp:RadioButtonList
id="{@name}" runat="server">
>
<xsl:for-each select="choice">
>
<asp:ListItem Value="{@value}">
             ^^^ where is the attribute value in your input xml on the
choice element?

>                 <choice>High School</choice>
>                 <choice>Some College</choice>
>                 <choice>College</choice>
                              ^^^ no attributes


> my question is why isn't the Value or Text of the ListItem being filled in?
I can't seem to put 2 and 2 together here.  Any links to help debug this would
be greatly apprecated.  Thanks all.

What do you expect it to fill in?  There's no attribute called value
anywhere in your XML as far as I can tell.

You're going over each node that is a question (//question) and doing
some output based on the values of the type attribute (the various
<xsl:if test="@type='blah'>. For the radio buttons you're applying a
chunk of code to each choice element.  You're trying to grab the value
attribute (@value) two times in that code block.

I'm guessing what you want is the text value of the current node.
(text value is perhaps a poor choice of words, but the value of
applying string to the various nodes as outlined in the Xpath and XSLT
specs). If you just want the value of the current node (ie choice) do
<asp:ListItem Value="{.}">
    <xsl:value-of select="."/>

...


see http://www.w3.org/TR/xslt#value-of

Jon Gorman

Current Thread