Subject: RE: [xsl] Newbie Question with @value From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 28 Mar 2006 22:28:00 +0100 |
The "choice" element in your data does not have an attribute called "value", so @value returns nothing. You want the string-value of the element, which you can get using ".". Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Falls, Travis D (HTSC, CASD) > [mailto:Travis.Falls@xxxxxxxxxxxxxxx] > Sent: 28 March 2006 20:59 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] Newbie Question with @value > > I have the following XSLT which is from an example: > <?xml version="1.0" encoding="UTF-8"?> > <xsl:stylesheet version="2.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:asp="remove"> > <xsl:output method="xml" indent="yes" encoding="utf-8" > omit-xml-declaration="yes"/> > <xsl:template match="/"> > <table> > <xsl:for-each select="//question"> > <tr> > <td valign="top"> > <xsl:value-of > select="@name"/> > <xsl:if > test="@required = 'yes'"> > > <asp:RequiredFieldValidator ErrorMessage="Required Field" > runat="server" ControlToValidate="{@name}"/> > </xsl:if> > </td> > <td> > <xsl:if > test="@type='text'"> > > <asp:TextBox id="{@name}" runat="server"/> > </xsl:if> > <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> > </xsl:if> > </td> > </tr> > </xsl:for-each> > </table> > <asp:button id="submit" runat="server" Text="Submit"/> > </xsl:template> > </xsl:stylesheet> > > 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 using XMLSpy (and with my C# code) > <table xmlns:asp="remove"> > <tr> > <td > valign="top">Title<asp:RequiredFieldValidator > ErrorMessage="Required Field" runat="server" > ControlToValidate="Title"/></td> > <td> > <asp:TextBox id="Title" runat="server"/> > </td> > </tr> > <tr> > <td valign="top">Industry</td> > <td> > <asp:TextBox id="Industry" runat="server"/> > </td> > </tr> > <tr> > <td valign="top">Education</td> > <td> > <asp:RadioButtonList id="Education" > runat="server"> > <asp:ListItem Value=""></asp:ListItem> > <asp:ListItem Value=""></asp:ListItem> > <asp:ListItem Value=""></asp:ListItem> > </asp:RadioButtonList> > </td> > </tr> > </table> > <asp:button xmlns:asp="remove" id="submit" runat="server" > Text="Submit"/> > > 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. > > Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 | > travis.falls@xxxxxxxxxxxxxxx > > Travis D. Falls | Consultant RAFT.Net IT | 860.547.4070 | > travis.falls@xxxxxxxxxxxxxxx > > > ************************************************************** > *********** > This communication, including attachments, is > for the exclusive use of addressee and may contain proprietary, > confidential and/or privileged information. If you are not > the intended > recipient, any use, copying, disclosure, dissemination or > distribution is > strictly prohibited. If you are not the intended recipient, > please notify > the sender immediately by return e-mail, delete this communication and > destroy all copies. > ************************************************************** > ***********
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Newbie Question with @val, G. Ken Holman | Thread | [xsl] for-each-group in xslt 2.0, Arulraj |
Re: [xsl] Displaying one section of, Gowri Ratakonda | Date | [xsl] for-each-group in xslt 2.0, Arulraj |
Month |