[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] 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! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|