Re: XMLPULL in C++

Aleksander Slominski <[email protected]>
Newsgroups gmane.text.xml.xmlpull.devel
Message-ID <[email protected]>
nickwoolley wrote:

> I've looked around a bit on Google and xmlpull.org, but can't see
> any signs of a C++ implementation of XMLPULL.

hi,

did you take look on XPP1 that has C++ implementation
of pull parsing, it is available in
 http://www.extreme.indiana.edu/xgws/xsoap/xpp/download/old_versions/PullParser11-OLD.tar.bz2

> Being impulsive, and being frustrated by the restrictions SAX2
> imposes upon my design (I want de/serialisable XML objects), the
> other night I had a go at writing a C++ pull parser implementing
> parts of the API.  I don't aim to make it perfect (yet), just
> usable. I got it compiling and running yesterday, but very
> imperfectly.

it takes some number of iterations to get things done ...

> I'm tidying up the first pass now, and I have a few questions, most
> relevantly:
>
> * Am I duplicating the efforts of someone else?

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).

what were your decisions about it? did you have any other problems?
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 ...


> But more specifically, when pondering how to expand / escape quoted
> attribute values (it seems that \ escaping isn't used, &entity;
> escaping is):

both escaping are valid - just using entities (such as &amp;) is safer
as the representation ("&amp;") can always be encoded no matter
what is document character encoding

> * If entities encountered in attribute values should be expanded,
> should this be signalled as a token?

it must be expanded and there is no token for attribute value(s).

> On the one hand you might want
> the user to know about his user-defined entities, on the other, how
> would this work, when a start tag as a whole is a token in itself?

i thin this is very rare case ie. need to retrieve tokens from attribute values
so when trying to make API easy for most of cases we have decided
that attribute values are always parsed. however we have provided
optional ability to do low-level access with ROUNDTRIP feature.

if ROUNDTRIP feature is supported one can retrieve whole start tag
content and parse it to extract anything (like entities used).

> i.e. How should this look, when parsing using XMLPULL?
>
> <tag attribute="some user defined &entity; &amp; another">

in this example when ROUNDTRIP is enabled you can call getText()
on START_TAG event to retrieve string with value
'<tag attribute="some user defined &entity; &amp; another">'

otherwise if ROUNDTRIP is not enabled getText() will return null

and in both cases calling getAttributeValue("", "attribute") will get you actual
attribute value "some user defined foo & another" assuming that entity
has replacement text "foo".

hope that it explains it.

thanks,

alek
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.