This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: default attribute values?
- From: "Thomas B. Passin" <tpassin at mitretek dot org>
- To: <xsl-list at lists dot mulberrytech dot com>
- Date: Fri, 12 Jul 2002 15:10:56 -0400
- Subject: Re: [xsl] default attribute values?
- References: <601F6322AD71D5118D6C0003472515290660CF22@sjmemexc1.stjude.org>
- Reply-to: xsl-list at lists dot mulberrytech dot com
[Hunsberger, Peter]
> > 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"/>
I think you mean <xsl:copy-of select="@type"/>, yes?
> <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.
>
Very slick!
Cheers,
Tom P
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list