XmlCodGen takes a description of an XML document structure and generates
one or both of the following:
- HTML documentation for the XML structure.
- .Net source code (C# or VB) for "business objects" that
read and/or write XML files with the defined structure.
For each XML element type, it generates source code for a partial .Net
class, with type-safe properties for each XML attribute and
child element.
Input files for XmlCodGen can also be used as templates for
XML Chameleon, an XML editor.
Invoking XmlCodGen
XmlCodGen is a command-line tool. It understands the following arguments.
Switches may be abbreviated to any unambiguous prefix.
-input fileName
- Specifies the name of the file that contains the XML specification
of the XML structure. The top-level element in this file must
be a Specification element.
-maxerrors integer
- Specifies the maximum number of errors to report before quitting.
Default = no limit.
-ifolder
- If this switch is specified, and none of the output files are
older than the input file, then the program quits without
generating anything.
-verbose
- Causes the program to output additional status information.
Does not affect the generated code or documentation.
Generated .Net Objects
For each XML element defined in the specification, XmlCodGen generates a
partial .Net class that contains the following public members:
constructor (XmlElement element, XmlObjectBase parent, ProgressReporter prgRpt)
-
Constructs an object from an XmlElement (DOM i/o).
Errors will be reported via the ProgressReporter.
virtual XmlElement ToXmlElement (XmlDocument doc)
-
Creates a new XmlElement for the object (DOM i/o).
The XmlElement is not added to the XmlDocument by this method.
virtual void WriteXml (XmlWriter w)
-
Writes the XML element (and its children) to the given XmlWriter.
virtual XmlObjectBase DeepClone (XmlObjectBase newParent)
-
Performs a deep copy of the object. The newParent parameter
is the parent for the new copy.
readonly int XmlSourceLine;
-
The line number in the XML file where the element was found.
readonly int XmlSourceOffset;
-
The line offset in the XML file where the element was found.
XmlObjectBase ParentObject;
-
The parent XML object, or null.
In addition to the above, the generated class will contain one public property
and one protected variable for each child and each attribute.
You can add application-specific methods by extending the partial class,
or by subclassing.
The XmlCodGen Library
The .Net code generated by XmlCodGen is dependent on a set of files
called the Library. This is not a DLL, because some of the files
contain partial classes that must be merged with classes in generated code.
The files are:
EnumValueDictionary.cs
HandleUnknown.cs
ProgressReporter.cs
XmlEntities.cs
XmlObjectBase.cs
XmlUtils.cs
External Dependencies
Both the XmlCodGen tool and the .Net code it generates require the following:
Essentials.dll (StauffConsulting.Essentials)
This documentation was generated by XmlCodGen version 0.2.1.37745 on Tue 18 Nov 2008 06:44 PM.
Software and documentation is copyright (c) 2006 by Edward L. Stauff.
All rights reserved.