Menu

Condensing space.

2003-12-30
2004-01-04
  • Simon Harrison

    Simon Harrison - 2003-12-30

    I'm new to the library, and have just started using 2.2.1.  It look pretty good, however, I'm having some problems...

    1) It appears the parser throws away leading/trailing whitespace regardless of the setting of CondenseWhiteSpace. Was that the intention?  It's a shame because it means if, say a config file starts off well formatted it doesn't stay that way.
    It's very easy to strip white space after extracting a value, or skip over space between nodes like:
    <a>___<child/>___<child/>___</a>
    using NextSiblingElement()

    not so easy to delve into the parser and try to bring back the spaces!

    2) The documentation appears to be wrong about White Space.  I think when you say "TinyXml supports the first 2 approaches" you mean "TinyXml supports the 2nd and 3rd approach" :-).

    3) FILE* serialisation is a nice idea but I can't find a open_memstream() equivalent on Windows, which means I have no portable way to get a formatted write to a buffer.  It would be nice if I could use sstream to get this effect.  In short, I'd love to be able to do a formatted Print() to an ostream - is there a way?

    4) The API is superb, very consistent, and to my mind more descriptive that DOM.  It seems like a lot of thought went into the method naming and it's paid off (if open-source ever pays :-)).  I spotted just one inconsistency, which is that GetDocument() should possibly be just Document()?

    5) Finally, is anyone using TinyXPath?  It seems quite interesting, but not currently maintained.

    thanks,

    -Simon.

     
    • Yves Berquin

      Yves Berquin - 2003-12-31

      A reaction to your #5 : TinyXPath was undergoing a major rewriting of the execution phase.

      It's ready now for beta. The new 1.1 version has been posted yesterday.

      Yves

       
    • Yves Berquin

      Yves Berquin - 2003-12-31

      More to the point (condensing space)

      It is quite straightforward to add a setting KeepOriginalSpacing (similar to the existing CondenseWhiteSpace) that would have the effect of keeping all the space, tabs, eol, etc ... characters in between elements and putting them in additional text nodes in between element nodes.

      This is mandatory if you want to reproduce the exact same output.
      The only difficulty I see is that if you create a tree yourself with this setting ON, you wouldn't get an indented tree on the output. But I guess this is really a minor issue, and you could revert to the OFF setting before you save a file you know you constructed yourself...

      Any thought on this ?

       
    • Simon Harrison

      Simon Harrison - 2003-12-31

      Well, for me, getting an indented tree is very low on my list of priorities (inspite of what I said above).  It's very rare that I want to construct a tree from scratch and I care how the user views it.  Far more likely that I perform a transform on a template which I hand-authored myself with the result either read by a browser or read by another program.  In either case I can send it through one of the more established parsers or another utility to get pretty-printing 'in-house'.

      I guess the trouble with XML is that people are putting it to uses nobody has thought of before. But for me, TinyXml is good because it's embeddable, and in embedded applications one rarely needs to pretty-print because the XML stuff is all happening behind the scenes.  Just my $0.02...

      -Simon.

       
    • Lee Thomason

      Lee Thomason - 2004-01-04

      Issues #1 and #2 sound like a bug or perhaps unintend behavior. It's been a long time since I've looked at the white space code in detail.

      I'll file it as an issue.

      #3...the short answer is no. You can only formatted print to a file. I'm not sure what structure I would support (without using STL) for formatted printing. It's a good idea, I just don't have an elegant and portable solution.

      #4 Thanks! (And the inconsistency is noted.)

      thanks,
      lee

       

Log in to post a comment.