This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: Multiple attributes present and non-present


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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]