XmlPlus Examples

How to try examples

The examples in the source package, come clean of generated code or makefile. Upon xsd2cpp invocation on the input schema file, the source and makefiles are generated. Please read the topic Tool Usage, to learn about xsd2cpp-usage, building generated source, and running the executables.

Each example directory, comes with following files:
  1. one or more XML-Schema file(s)
  2. a valid.xml file(a valid XML file for reference)
  3. a main.cpp file
As mentioned earlier, xsd2cpp usage is:

$ xsd2cpp
Usage:
1. xsd2cpp xsd-file [outdir]
    outdir: directory to output the generated source, like foo, . , .. etc.
    (if unspecified, defaults to xsd-file-name)

2. xsd2cpp -v
    prints version

3. xsd2cpp -h
    prints help



To try examples, all you have to do is to, run xsd2cpp in the respective examples directory with output directory specified as "." and then build.
Each example directory is already provided with the main.cpp having populateDocument() function already filled.

You can of course, experiment with the code in the main.cpp, especiallly with the template functions:
void populateDocument(DOM::Document* pDoc)
void updateOrConsumeDocument(DOM::Document* pDoc)
Note that, for writing sample XML document, roundtripping XML document, or validating XML document you don't have to fill the above mentioned functions in main.cpp file.

It is recommended that you use outdir as ".", for examples because: If for whatever reason you have specified a outdir other than ".", then you would need to: Here is an example xsd2cpp run of simpleTypesDemo example:

$ cd simpleTypesDemo/
$ xsd2cpp simpleTypesDemo.xsd .
output path: .
=> Generating source files...
=> Generating automake/autoconf files ...



For building the source in the outdir:
$ ./autogen.sh
$ make
$ make install
$ make doxygen-doc



After successful build and install, you should have a run binary installed. Use this run binary to try out the available options.
An example of <name>run options:
$ ./build/bin/simpleTypesDemorun --help
Usage: ./build/bin/simpleTypesDemorun [options] [XMLfile]
Options:
 -s, --sample
   create a schema-driven sample xml-file
 -w, --write
   write a xml-file using populated Document
   Note: populateDocument() function in main.cpp template,
   must be used to populate the Document
 -v, --validate
   validate input xml-file(against compiled schema)
 -r, --roundtrip
   roundtrip (read->write) input xml-file
 -u, --row
   perform read->operate->write operations on input xml-file
 -h, --help
   print help



Build and test all of examples/ and Tests/ directories

There is a script named runTests.sh in source home. The options for this script are:

$ ./runTests.sh -h

Usage:
$ runTests.sh  [-c | -t]
  -c  cleanup all the test directories
  -t  cleanup and test all the test directories
  -h  print help

  (test directories include: Tests/ examples/) 
  

The options are self-explanatory. When run with -t option, this script iteratively builds and tests all examples and Tests directories(though it takes long to finish).
If you want save the effort of building all examples(and Tests directories) one by one, before you could experiment with the respective builds, running "runTests.sh -t" may be a good idea.
Please be informed that with both "-c" and "-t" options, this script cleans up the Tests and examples directories recursively, of files that it thinks are temporary files(it does warn you about about the same and requests your permission before proceeding). If you have important changes in those directories, those changes should be backed up before proceeding with this script.

Examples by tags

Find examples by tags
Example Associated Tags
helloWorld Schema components: element
BuiltIn Types: string
helloWorldWide Schema components: element
BuiltIn Types: string
Facets: maxLength
Other Tags: wide characters
simplest Schema components: complexType, element, attribute
BuiltIn Types: string
Schema controlled Attributes: elementFormDefault
Other Tags: targetNamespace, mixed content
simpleTypesDemo Schema components: complexType, simpleType, element, attribute
Schema controlled Attributes: elementFormDefault, attributeFormDefault, minOccurs, maxOccurs, fixed
simpleType variety: atomic, union, list
BuiltIn Types: boolean, decimal, float, double, integer, positiveInteger, nonPositiveInteger, negativeInteger, nonNegativeInteger, long, int, short, byte, unsignedLong, unsignedInt, unsignedShort, unsignedByte, hexBinary, base64Binary, anyURI, normalizedString, token, language, Name, NCName, QName, dateTime, date, gYearMonth, gYear, gMonthDay, gMonth, gDay, time, duration, ID, IDREF, IDREFS, ENTITY, ENTITIES, NMTOKEN, NMTOKENS
Facets: minLength, minInclusive, maxInclusive, minExclusive, maxExclusive, pattern etc.
Other Tags: targetNamespace, mixed content, attribute/element sharing common name
purchaseOrder Schema components: complexType, simpleType, element, attribute, anonymous element
Schema controlled Attributes: minOccurs, maxOccurs, fixed
Facets: pattern
mails Schema components: complexType, simpleType, element, attribute
Schema controlled Attributes: minOccurs, maxOccurs
Facets: enumeration
Other Tags: Model Group 'sequence' with maxOccurs="unbounded"
includeDemo Schema components: complexType, simpleType, element, attribute, include
Schema controlled Attributes: minOccurs, maxOccurs
organization Schema components: complexType, simpleType, element, attribute, import
Schema controlled Attributes: minOccurs, maxOccurs
Other Tags: targetNamespace, nested imports
many more examples... Please check out yourself under examples directory. You could also browse examples and Tests using links below.

Browse Examples With Generated Source

The examples in the source package, come clean i.e. they don't have the generated source with themselves already. Upon xsd2cpp invocation on the input schema file, the source and makefiles are generated. It is not practical to list out generated source for all examples, as it gets very verbose and long.

Please follow this link, to view a few examples with generated source: Samples of Generated Source

Browse Examples and Tests

The complete list of examples and tests(excluding generated source) for browsing.