[xsd-users] XSD questions

Boris Kolpackov boris at codesynthesis.com
Wed Jun 23 13:37:29 EDT 2010


Hi Bruce,

Bruce Allen <claudevms at comcast.net> writes:

> I am having trouble with the hello example program. The documentation 
> on the web site refers to the C++ parser?, --xml-parser which is expat,
> but when I look at the xsd /? command there are no switches that refer 
> to the C++ or XML parsers?

You are most likely using Microsoft XSD.exe (which is a .NET XML Schema
compiler) instead of CodeSynthesis XSD. For more information on this
issue see the "Conflict with Microsoft xsd.exe" section in the Using XSD 
with Microsoft Visual Studio wiki page:

http://wiki.codesynthesis.com/Using_XSD_with_Microsoft_Visual_Studio
 
In addition, if you want to be able to run XSD from the command
line, you will need to add the path to the bin/ directory in the
XSD distribution to the PATH environment variable (using the .msi
installer is a great way to make sure this is done automatically).


> Also, how do I specify that I want to Xerces-C++?

In the C++/Parser mapping, Xerces-C++ is the default XML parser so
you don't need to specify any additional options.
 
 
> Does XML and an XML parser take the place of LEX and YACC? I have used 
> them in the past. I'm trying to see the road map here. Do I create XML 
> files for input to my applications and use XSD to generate classes for
> my application? Then my application can call the methods in these 
> classes to read in my XML files?

Not exactly. You use XML to "store" or "encode" data. The XML 
documents can be written by you or they can be created by programs.
Once you "specialize" the XML language to encode your specific data
(for example, people in the organization or books in the library),
then you have created an "XML vocabulary". A formal way to describe
a vocabulary is to create an XML Schema definition (.xsd) for it.
The schema can then be given to the CodeSynthesis XSD compiler which
will produce the C++ classes corresponding to your XML vocabulary.
These classes are called the "object model". The object model
represents the data stored in your XML documents and can be used
to extract that data from XML or to store it back to XML.   
 
There are also multitude of tutorials on XML and XML Schema available
on the web.

> The C++/parser seems to allow an application to read and write XML 
> and that is because the xerces code?

The C++/Parser mapping is actually a fairly specialized XML Schema
to C++ mapping in that it does not create an in-memory representation
of the data stored in XML but rather sends the data to the application
via callback functions to be handled as it is parsed.

If you are new to XML then a much better mapping to start with would
be C++/Tree:

http://www.codesynthesis.com/products/xsd/c++/tree/

The getting started guide for this mapping is here:

http://www.codesynthesis.com/projects/xsd/documentation/cxx/tree/guide/


> I tried the wiki page to integrate the XSD tool into Visual C++ 2008 
> but it the instructions for the menus don't match whats in the 2008 
> version.

That's probably because you haven't set the rule files paths correctly
or haven't enabled them in your project. The wiki page has the step-
by-step instructions:

http://wiki.codesynthesis.com/Using_XSD_with_Microsoft_Visual_Studio#Visual_Studio_2005_.288.0.29_and_2008_.289.0.29
 
Boris



More information about the xsd-users mailing list