[xsl] Creating an input form, XML -> XSLT -> HTML

Subject: [xsl] Creating an input form, XML -> XSLT -> HTML
From: Dan Cederholm <dan@xxxxxxxxxxxx>
Date: Sun, 30 Dec 2001 13:31:28 -0600 (CST)
> Hi,
>
> I want to take XML and generate an input form using XSLT. In straight
> HTML, I would code this:
>
> <INPUT TYPE = "TEXT" NAME="FIRSTNAME" VALUE="JAMES" >

I believe the proper way would be like this:

<INPUT TYPE="TEXT" VALUE="JAMES">
	<xsl:attribute name="NAME">
		<xsl:value-of select="$foo"/>
	</xsl:attribute>
</INPUT>

Where "$foo" could be XPath or a variable.

I've run into having to create a unique NAME for several values and did
this:

<xsl:for-each select="/foo/bar">
	<xsl:variable name="uniqueID">
		<xsl:text>FIRSTNAME_</xsl:text>
		<xsl:value-of select="position()"/>
	</xsl:variable>
	<INPUT TYPE="TEXT">
		<xsl:attribute name="NAME">
			<xsl:value-of select="$uniqueID"/>
		</xsl:attribute>
	</INPUT>
</xsl:for-each>

This will run through all the /foo/bar's and give them FIRSTNAME_1,
FIRSTNAME_2, FIRSTNAME_3, etc.

Not sure if that's what you wanted to do exactly...

Dan Cederholm

--
http://www.cederholm.tv
dan@xxxxxxxxxxxx



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread