Re: [xsl] Newbie Question with @value

Subject: Re: [xsl] Newbie Question with @value
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 28 Mar 2006 15:11:04 -0500
At 2006-03-28 14:58 -0500, Falls, Travis D (HTSC, CASD) wrote:
I have the following XSLT which is from an example:
...
                                                <xsl:if test="@type='radio'">

<asp:RadioButtonList id="{@name}" runat="server">

<xsl:for-each select="choice">

<asp:ListItem Value="{@value}">

<xsl:value-of select="@value"/>

</asp:ListItem>

</xsl:for-each>

</asp:RadioButtonList>
...
I have the following XML file:
<?xml version="1.0" encoding="utf-8"?>
<survey name="Example Survey">
        <question type="text" name="Title" required="yes"/>
        <question type="text" name="Industry"/>
        <question type="radio" name="Education">
                <choice>High School</choice>
                <choice>Some College</choice>
                <choice>College</choice>
        </question>
</survey>

and I get the following output
...
                      <asp:RadioButtonList id="Education" runat="server">
                                <asp:ListItem Value=""></asp:ListItem>
                                <asp:ListItem Value=""></asp:ListItem>
                                <asp:ListItem Value=""></asp:ListItem>
                        </asp:RadioButtonList>
..
my question is why isn't the Value or Text of the ListItem being filled in?

I don't see any attributes named value= in your source XML.


I can't seem to put 2 and 2 together here.

The stylesheet is addressing a value attribute using "@value", and yet your XML element with @type='radio' does not have a value= specification. And it is not an error in XPath to address something that isn't there ... you just get the empty string.


I hope this helps.

. . . . . . . Ken

--
Registration open for XSLT/XSL-FO training: Wash.,DC 2006-06-12/16
World-wide on-site corporate, govt. & user group XML/XSL training.
G. Ken Holman                 mailto:gkholman@xxxxxxxxxxxxxxxxxxxx
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Box 266, Kars, Ontario CANADA K0A-2E0    +1(613)489-0999 (F:-0995)
Male Cancer Awareness Aug'05  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal

Current Thread