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

Guidelines for handling of elements' content?

  • To: xml-dev@l...
  • Subject: Guidelines for handling of elements' content?
  • From: Ralf <ralfml@a...>
  • Date: Tue, 23 Sep 2003 22:29:09 -0700
  • Organization: Alfray Inc.
  • User-agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.4) Gecko/20030624

libxml ignore whitespace
Hi!

Disclaimer: this is a newbie question. Please email me offlist if my 
question is best answered somewhere else. Flames burn. Thanks in advance.

I'm parsing a SVG file using libxml2 and for each element node I get its 
content. [Note: this is not an SVG nor libxml2 specific question]
This turns out to be a concatenation of all the "text" located between 
the node' list of children, recursively, including spaces and end of 
lines. Fine, that's what the XML specs says will happen (not that I 
understand the logic of it).

This content contains both the xml user content (i.e. the "real" 
content) and the xml text file "format" content.
My real question is how do I use that content? How do I design my XML?
How do I know that the spacing matters, or that the \n matters or are 
just a byproduct of the XML text file?
Is it best to remove all spacing and \n after and before any kind of 
non-whitespace content?
Sure xml:space tells me I should preserve them or not... really? The 
specs doesn't tell me much about it. It just says the application gets 
it all or knows what to do with it. Well personnally I don't. What about 
"good behavior" guidelines for applications?

Here I'm dealing with SVG (typically <text> and <tspan>) but I already 
had the problem with other custom xml formats.]

A typical example that confuses me:

<text>    this
   is a text   .
     </text>

What should I interpret here? One straight line, one line with one \n in 
the middle, or one with thre \n ? What about the spaces before "is" and 
"this"?
Currently what I do is ignore any whitespace (space, \t and \n) before 
and after the non-whitespace content. Everything inside I keep.

FAQs pointers or other welcome offlist.

Thanks in advance.
Raphael



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.