[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Newbie Question with @value

Subject: RE: Newbie Question with @value
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Tue, 28 Mar 2006 22:28:00 +0100
radiobuttonlist required field
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:  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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Cast Your Vote

We need your help – Vote for DataDirect XML Products!

  • Best SOA or XML site

Winners and finalists announced at SOA World Conference in November.

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.