Lightweight XSD validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Martin Halle

    #1

    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.
  • Boris Kolpackov

    #2
    Re: Lightweight XSD validation

    Hi Martin,

    Martin Halle <martin.halle@g mx.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

    Comment

    • Martin Halle

      #3
      Re: Lightweight XSD validation

      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.

      Comment

      Working...