This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
Re: Multiple attributes present and non-present
- From: Wendell Piez <wapiez at mulberrytech dot com>
- To: xsl-list at lists dot mulberrytech dot com
- Date: Mon, 04 Mar 2002 15:03:51 -0500
- Subject: Re: [xsl] Multiple attributes present and non-present
- References: <001801c1c3a5$0a695560$66816bd5@pcukmka>
- Reply-to: xsl-list at lists dot mulberrytech dot com
Mike,
At 01:22 PM 3/4/2002, you wrote:
>I was looking for a way to copy all the attributes of any element in
>my xsl:stylesheet. I stumbled on to this (below). I have not found
>an example of copy-of being used this way. Should I use a different
>method?
No, if you want to copy all attributes, this works fine.
>Also it would be nice not to have the empty attributes (taken from my
>dtd probably) appear. How can I null this consequence?
If you want to avoid attributes whose value is the null string, then do
<xsl:copy-of select="@*[string(.)]
which copies only those attributes whose string value tests as true (is
non-null). If you want to eliminate also attributes that have only
whitespace, do
<xsl:copy-of select="@*[normalize-space(.)]
Attributes which have a default in the DTD will still be copied.
Unfortunately, the XSLT data model does not preserve information about
whether an attribute value was provided by default.
Cheers,
Wendell
======================================================================
Wendell Piez mailto:wapiez@mulberrytech.com
Mulberry Technologies, Inc. http://www.mulberrytech.com
17 West Jefferson Street Direct Phone: 301/315-9635
Suite 207 Phone: 301/315-9631
Rockville, MD 20850 Fax: 301/315-8285
----------------------------------------------------------------------
Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list