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

RE: default attribute values?

Subject: RE: default attribute values?
From: "Hunsberger, Peter" <Peter.Hunsberger@xxxxxxxxxx>
Date: Fri, 12 Jul 2002 13:43:53 -0500
xslt copies default values
> Is there a way to ignore an attribute or give it a default value if one
> wasn't set?

This came up as a side issue to a question I asked a couple of weeks ago.  A
fairly elegant solution relies on the fact that if an attribute is multiply
defined the last instance is used.  It also exploits the fact that a copy-of
only copies if there is something to copy. Eg:

	<input type="text">
		<xsl:copy-of select="@text"/>
		<xsl:copy-of select="@value"/>
		<xsl:copy-of select="@size"/>
		<xsl:copy-of select="@maxsize"/>
	</input>

will give the type attribute a default of "text" and override it with any
supplied only if there is in fact a text attribute.  The rest of the
attributes are only created if they were passed in.


 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.