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

Re: attributes vs. elements


Re:  attributes vs. elements
Alessandro Triglia scripsit:

> > From: mgushee@h... [mailto:mgushee@h...] 
> >   * White space in elements can be preserved, whereas white space in
> >     attributes is normalized (leading and trailing spaces are stripped,
> >     each extent of internal white space is collapsed to a single space
> >     character).
> 
> I don't follow you.  If the schema is specified in XML Schema and the
> datatype of an attribute is "string" (whose "whitespace" facet is
> "preserve" by default), I don't believe white space is normalized. 

Whitespace normalization depends on the DTD, if any.  If an attribute
is declared in the DTD as of type CDATA, or is not defined in the DTD, or
the parser does not read the relevant part of the DTD, then minimal
normalization of its value is done: namely, tabs, newlines, and CRs are
changed to spaces.  A CR can only exist in an attribute value by the
use of Stupid DTD Tricks.

If the attribute is declared in the DTD with a type other than CDATA, and the
parser knows it, then further normalization is done: leading and trailing
spaces are removed, and all other runs of spaces are collapsed to a single
space.

All this is done conceptually *before* any XML Schema processing is done.
Nothing analogous is done to character content, So:

> an attribute of type "string" behaves differently from
> an element of type "string" as to white space handling?

Yes.

-- 
Knowledge studies others / Wisdom is self-known;      John Cowan
Muscle masters brothers / Self-mastery is bone;       jcowan@r...
Content need never borrow / Ambition wanders blind;   www.ccil.org/~cowan
Vitality cleaves to the marrow / Leaving death behind.    --Tao 33 (Bynner)

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.