Re: LibXML2 Indentation



Ali Akcaagac wrote:

On Wed, 2003-04-30 at 00:23, Havoc Pennington wrote:
<stringvalue>9</stringvalue>
...
 <stringvalue>
  9
 </stringvalue>
The difference is that in the second case the string stored is "\n 9\n
" and in the first case it is "9".  If you didn't do this, you
couldn't store strings containing whitespace.

Yes right, I could have thought about this one scenario myself and yes
this is quite correct and maybe a bad choosen example from my side. But
we could indent complete TAG's in general e.g.

<?xml version="1.0"?>
<gconf>
<entry name="accuracy" mtime="14" muser="galaxy" type="string">
 <stringvalue>9</stringvalue>
</entry>
</gconf>

and this one gives us no sideeffects the Tag's are indented more human
readable and the data is placed between the start and endtag saving us
from having eiter $a, $d or both (e.g. on Windows that adds two bytes
for linebreaks). Isn't this possible ?

In your example above, the child list of the <entry> element is the text node "\n " followed by a <stringvalue> element followed by a text node "\n ".

For the white space not to matter, the application will need to handle the cases where it is present. For example, if the application is expecting the first child node of <entry> to be the <stringvalue>, then it will fail if whitespace is included.

The only place in an XML file where whitespace truely is insignificant is within tags. For instance, the following two fragments are equivalent:
 <foo bar="baz"> </foo>
and:
 <foo
 bar="baz"> </foo>

James.

--
Email: james daa com au
WWW:   http://www.daa.com.au/~james/






[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]