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

Re: Outputting XML to hidden HTML form fields

Subject: Re: Outputting XML to hidden HTML form fields
From: David Carlisle <davidc@xxxxxxxxx>
Date: Mon, 15 Jan 2001 17:55:27 GMT
hidden xsl
> I need to output a raw XML node to a hidden HTML form field.

There are two things to note here. Firstly in the XPath tree model
of an XML document (and most other models) Attributes
do not contain element nodes, only text.

Also in the linearisation of an XML file in XML syntax, an attribute
value may not contain an unescaped < you have to use &lt;.


<input type="hidden">
	<xsl:attribute name="name">
		_desc_<xsl:value-of select="id"/>
	</xsl:attribute>

	<!-- the above works fine. -->

The above is OK, but could more easily have been written
<input type="hidden" name="_desc_{id}">

(assuming you didn't really want the white space before _desc_)


	<xsl:attribute name="value">
		<xsl:copy>

You haven't shown your full template so I don't know for sure what is
the current node at this point, but probably it's the item node.
copying any element node into an attribute value is not going to work
for the reasons above.

What I think you want is
<xsl:attribute name="value">
  <xsl:text>&lt;item&gt;</xsl:text>
  <xsl:for-each select="*">
  <xsl:text>&lt;</xsl:text>
	<xsl:value-of select="name(.)"/>
  <xsl:text>&gt;</xsl:text>
	<xsl:value-of select="."/>
  <xsl:text>&lt;/</xsl:text>
	<xsl:value-of select="name(.)"/>
  <xsl:text>&gt;</xsl:text>
  </xsl:for-each>
  <xsl:text>&lt;/item&gt;</xsl:text>
</xsl:attribute>

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet delivered
through the MessageLabs Virus Control Centre. For further information visit
http://www.star.net.uk/stats.asp

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


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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

Buy Stylus Studio Now

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-2013 All Rights Reserved.