468,513 Members | 1,506 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,513 developers. It's quick & easy.

Lightweight XSD validation

Dear all,
I'm using XML in a project. This is a very simple and small file that
follows an even simpler XSD schema. I've found a lightweight library
(TinyXML) to read and access the contents of the XML file in C++.
Now I'm looking for something similar to validate a given XML file
agains a XSD schema. This library should:
- be lightweight (!)
- thus not depend on xerces, MSXML and similar
- cross-platform (g++) compatible
- can use STL (this would be a nice-to-have)
Any idea would be greatly appreciated.
With best regards, Martin.
Aug 3 '06 #1
2 13628
Hi Martin,

Martin Halle <ma**********@gmx.netwrites:
I'm using XML in a project. This is a very simple and small file that
follows an even simpler XSD schema. I've found a lightweight library
(TinyXML) to read and access the contents of the XML file in C++.
Now I'm looking for something similar to validate a given XML file
agains a XSD schema.
General-purpose XML Schema validators are usually neither simple nor
lightweight ;-). You might be interested in the so called "perfect
parser" approach where the validation code is generated by a tool
specifically for your schema. If your schema is fairly simple then
the resulting code will be small as well. A well-implemented perfect
parser will also perform several times faster than general-purpose
validators.

One such tool is CodeSynthesis XSD[1] and its C++/Parser mapping[2]
(full disclosure: I am working on this project). It is an open-source
(GPL + proprietary license), cross-platform XML data binding compiler
for C++.

This library should:
- be lightweight (!)
Executable size for a small schema (our benchmark) is around 250K.

- thus not depend on xerces, MSXML and similar
It uses Expat as the underlying XML parser. Expat is fairly small
and is the fastest among Xerces-C++, MSXML, and libxml2.

- cross-platform (g++) compatible
Check. See the list of supported platforms and compilers[3].

- can use STL (this would be a nice-to-have)
Uses standard C++ and STL.
[1] http://codesynthesis.com/products/xsd/
[2] http://codesynthesis.com/products/xsd/c++/parser/
[3] http://codesynthesis.com/products/xsd/platforms.xhtml
hth,
-boris
Aug 3 '06 #2
Dear Boris,

thank you for your answer.
One such tool is CodeSynthesis XSD[1]
and its C++/Parser mapping[2]
Guess what: When doing the "googleing" this was the one that came
closest to what I had in mind. I'm glad you point to this, too. I was
hoping that there is an even smaller one but I understand the complexity
of a XML schema validation. Hence what would be enough for me is a
structure, data-type and data-range check in a fairly XML flat structure
and that would be it. Anyway, thanks a lot for your answer - so I guess
I'll stick with [1] and [2] and give it another try. (I had some
troubles compiling this in the first place but I'll try again...)

With best regards, Martin.
Aug 4 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Jeremy Hylton | last post: by
2 posts views Thread by build | last post: by
1 post views Thread by Guinness Mann | last post: by
reply views Thread by tjr7933 | last post: by
3 posts views Thread by javaBookWorm | last post: by
reply views Thread by NPC403 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.