c++xsdxerceslocal-filescodesynthesis

XSD to C++ class using xsd cxx-tree parser. Methods to open a xml from a file.


I'm usign the xsd 3.3.0 Compiler in order to parse a xsd (xml best friend) file to C++ class. (see last weblink)

The comand name is

xsd cxx-tree (options) file.xsd

(+ info http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/)

I've seen some examples provided by codesynthesis where they parse a hello.xsd document and creates a .hxx and a .cxx file very easily. The .hxx has a method to open a xml document creating an object where you can find the diferent parts of the xml, check it, etc... The .hxx has a code like this:

// Parse a URI or a local file.
//

::std::auto_ptr< ::hello_t >
hello (const ::std::string& uri,
       ::xml_schema::flags f = 0,
       const ::xml_schema::properties& p = ::xml_schema::properties ());

It receive a string with the file name

string& uri = "hello.xsd"

and create the object that you use in the main.cxx.

So, I'm trying to do the same with my xsd file. I use the xsd cxx-tree compiler but it doesn't create the methods to "Parse a URI or a local file.". Then I can't create an object from a xml file on my main program.

I solve some compiling problems using differents options from codesys compiler documentation (http://www.codesynthesis.com/projects/xsd/documentation/xsd.xhtml). There are differents options about what do you want to compile, how do you want to do it, etc... but I can't find any options to enable the methods used to "Parse a URI or a local file.".

Giving more onformation, the xml-xsd documents are CBML protocol documents.

Thank you for your help!


Solution

  • I found the solution by myself!

    I used different options for compiling. I used the option "--root-element library" and it caused that the methods to "Parse a URI or a local file." wasn't created.

    I delete this option and I added "--root-element-all" that create parse methods for all principals objects!

    Now my program works! thanks!