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

Why many XML Editors don't preserve whitespace nodes

  • From: Philip Fearon <pgfearo@googlemail.com>
  • To: xml-dev@lists.xml.org
  • Date: Sun, 14 Nov 2010 20:11:57 +0000

Why many XML Editors don't preserve whitespace nodes
Dear list,

This question relates to yesterday's previous thread 'why whitespace
counts as a node'. Here, it was agreed that, so far as XML parsers are
concerned, whitespace within mixed content must be significant. Given
this, I'm interested in list members views on what an XML text editors
treatment of whitespace should ideally be like.

So, taking as an example, the following.

<abc>
<new>this<b>is</b> <b>ok</b></new>
<b>this</b> <i>or</i> <b>this</b>
</abc>

If I copy this into the XML text editors of three XML IDEs (the most
popular ones I know of that work on my OS), and then press the 'pretty
print' or 'indent' button, some or all of the the single space
character (&#x20;) whitespace nodes are replaced by the newline
character (&#x0A;) followed by padding spaces or tabs, to provide
indenting, I'll just include one example output here:

<abc>\n
    <new>this<b>is</b>\n
        <b>ok</b></new>\n
    <b>this</b>\n
    <i>or</i>\n
    <b>this</b>\n
</abc>

Is this what you would expect, is it desirable. is it even important?
I would prefer the following output which a plain text editor with XML
plugin provides:

<abc>
      <new>this<b>is</b> <b>ok</b></new>
      <b>this</b> <i>or</i> <b>this</b>
</abc>

[Note: I've looked at all the whitespace handling options for one of
these IDEs (there are quite a few!), and these options change how
whitespace is first treated either when XML is loaded or typed, but
not the behaviour of the 'pretty print' option]

Also, I like XML indenting, but why is it even necessary to use
padding characters in XML editors to achieve this, is this just legacy
text editor stuff? What's wrong with using appropriate line indents
that are associated with each newline character? Then, when typing in
the editor, each time I choose to insert a new line, the text cursor
shifts to the next line and appears indented as expected, but with no
preceding tab or space characters on that line.

This approach would allow copy and paste to work with indentation
being automatically resolved, indentation couldn't be wrecked by
deleting text, and it would also be easier to switch between XML
editors. Of course, you would still need a capability to remove all
those padding characters inserted by XML editors or XML serializers
with the 'indent' option set...

Thanks

Phil Fearon
http://qutoric.com


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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.