Re: XMLPULL in C++

Nick Woolley <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
Hi,

thanks for your prompt reply Alek, sorry mine wasn't so.

--- In xmlpull-dev@y..., Aleksander Slominski <aslom@e...> wrote:
   > nickwoolley wrote:
   > did you take look on XPP1 that has C++ implementation
   > of pull parsing, it is available in [snip]

Ah - I looked around for it in there, (because there was a mention of a
C++ binding at the site, in an article on IBM's developer world or
somewhere).  I didnt find it though, and there was no mention of C++
on the site that I could find - it looked like only Java was supported.

   > i want eventually to convent MXP1 code from Java to C++ (when
implementing
   > i have made code very easy to convert ..) bu ti need first to figure
   > out the best ways to represent String (UTF-8, UTF-16 other encodings)
   > that internally keeps wchar_t* or char* and how to abstract IO
processing
   > (so streaming works OK).

Have you any references you could give me to help me understand exactly
what you mean here?  Can you not define the XMLParser as a template
class to solve the latter. as is done with C++'s  basic_string<> class?
     And what IO streaming do you mean which can't be handled by C++
streams?

Incidentally, I was wondering about an isalpha() function or similar
that was locale specific - my Stroustrup book doesn't say whether these
functions are or not.

   > what were your decisions about it?

Well, depends what you mean.  I saw there was a need which pull parsing
seemed to satisfy quite nicely, but there weren't any handy parsers I
could take "off the shelf".  I tried SAX2 but it seemed like I had to
bend over backwards to get it to do what I wanted.

So I thought, maybe I can write a simple implementation based on this
which could do what I need to do, and then later if the C++ version
turns up I can switch to that without much effort.

   > did you have any other problems?

Getting a basic prototype wasn't too hard.  Figuring what to do to make
the semantics comply to the XMLPULL API isn't always easy, I have lots
of questions here.

I've written about three versions now, I think they are getting better
as implementations of the API but I want to stop working on the parser
and start using it to solve my problem.

   > i think those are the only issues when i was implementing XPP1 (and
   > learnt hard way how important they are). i think that eventually we
should
   > put together C++ binding for XmlPull API ...

I'd be happy to contribute if I can, and I if have time.

   > hope that it explains it.

Yes thanks.  I hope you don't mind if I ask some more questions?

--

Firstly, is there a test suite I could (at some point) adapt to check if
the compiler parses XML correctly, as per the API spec.? I'm thinking of
some XML files and lists of the output events and their atttributes
which should be generated from them.

--

Secondly, does next() skip whitespace, like nextTag()?

--

Should nextTag() create end tag events for empty tags?

--

Why are some event ids defined as type 'byte', and others as 'int'?

--

Does the API specify whether text has to be returned as one contiguous
chunk, or if a sequence of tokens is acceptable?

i.e. given a doc:

<?xml version="1.0"?>
     stuff
<roottag>
     <anothertag>  do be do be do &amp; do  </anothertag>
</roottag>


When using nextToken(), this is what you might expect to get back:

TEXT = "do be do be do "
ENTITY_REF = "&amp;"
TEXT = " do  "

But might you also get:

TEXT = "do"
TEXT = " "
TEXT = "be"
TEXT = " "
....

Or even:

TEXT = " do be do be do & do  "




Cheers,

Nick
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.