Subject: Re: xsl:attribute with html option tags From: "Dan Machak" <machak@xxxxxxxxxxxx> Date: Mon, 4 Oct 1999 14:06:24 -0700 |
On Oct 4, 1:13pm, Ken Schneider wrote: > Subject: xsl:attribute with html option tags > > Hi, > > > <select size="1" name="security_level"> > <option> </option> > <option>1</option> > <option>2</option> > <option>3</option> > <option>4</option> > <option>5</option> > </select> > > In order to use the "xsl:attribute" like I used with text fields, I'd > need to know ahead of time which <option> tag to place it in... > correct? But since I'm reading the number in from the xml, this implies > I'd have to dynamically generate the <options> using javascript? Or is > there an easier way? > I'm working on pretty much the same problem, using user customized data to generate a form. The approach I'm taking has the form data and user preferences in separate xml files. Here is an example that has the form data and user data in the same file for conciseness: option.xsl: <xsl:stylesheet xmlns:xsl="http://www.w3.org/XSL/Transform/1.0"> <xsl:param name="user">jdoe</xsl:param> <xsl:output indent="yes"/> <xsl:template match="/"> <xsl:call-template name="make-select"/> </xsl:template> <xsl:template name="make-select"> <select size="1" name="security_level"> <xsl:for-each select="//security_options/option"> <option> <xsl:if test="./text()=//user[@user_id=$user]/@security_level"> <xsl:attribute name="selected"/> </xsl:if> <xsl:value-of select="./text()"/> </option> </xsl:for-each> </select> </xsl:template> </xsl:stylesheet> data.xsl: <data> <users> <user user_id="jdoe" security_level="3"/> </users> <formdata> <security_options> <option> </option> <option>1</option> <option>2</option> <option>3</option> <option>4</option> <option>5</option> </security_options> </formdata> </data> Output: (using XT19990813) <select size="1" name="security_level"> <option> </option> <option>1</option> <option>2</option> <option selected="">3</option> <option>4</option> <option>5</option> </select> Is this the kind of thing you were thinking of? Dan > > [ text/plain ] : > > This email and any files transmitted with it are confidential and intended > solely for the use of the individual or entity to whom they are addressed. > If you have received this email in error please notify the system manager. > This footnote also confirms that this email message has been swept by > TREND InterScan for the presence of computer viruses. >-- End of excerpt from Ken Schneider -- <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> <> Dan Machak <> machak@xxxxxxxxxxxx <> <> MS T27A-1 <> 650-604-2388 (VOICE) <> <> NASA Ames Research Center <> 650-604-3957 (FAX) <> <> Moffett Field, CA 94035-1000 <> <> <><><><><><><><><><><><><><><><><><><><><><><><><><><><><><> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
xsl:attribute with html option tags, Ken Schneider | Thread | for-each: Sorting and Grouping, Hyatt, Steve (IndSys |
RE: A problem with [embedded templa, Hunter, David | Date | XSL Tutorial links??, Joy Daniel |
Month |