Generated Reader and Writer Programs
Another capability that is related to -genTest is the capability to generate sample reader and writer programs. These can act as guides or templates in developing more advanced applications.
The -genReader option causes a reader program (reader.c) to be generated. This program will read data from a file containing an XML document and decode the document into a corresponding data structure. The data structure to be used will either be chosen randomly from the provided schema file, or the -usepdu option may be used to select the global element to be used.
The -genWriter option causes a writer program (writer.c) to be generated. The global element to be used as the basis for this program can be selected using -usepud option as was done for the reader above. If -genTest was specified at the same time as -genWriter, a section will be added to the writer to populate a data structure with test data for encoding. If -genTest was not specified, a "TODO" section is added to the writer to allow the user to add their own code to populate a variable of the type to be encoded.
The -genRWTest option causes a read/write program to be generated. This reads in a document of a given XML schema type (as above, this may be specified using -usepdu), decodes it, and then reencodes iand writes the document back out. This can be useful for doing transformations on a document such as automatically changing the values of certain fields. It is also useful for round-trip testing.
The -exi and -zip options can be used in conjunction with -genReader and -genWriter switches to produce programs that will read and write documents in compressed form. The -exi option causes schemaless EXI encoding to be done on the document as specified in the first public working draft of the W3C Efficient XML Interchange specification (http://www.w3.org/TR/2007/WD-exi-20070716/). Also, -c14n can be used to produce a writer program that will output an XML document in canonical form.
Copyright © Objective Systems 2002-2008 This document may be distributed in any form, electronic or otherwise, provided that it is distributed in its entirety and that the copyright and this notice are included. |
Objective Systems, Inc.55 Dowlin Forge RoadExton, Pennsylvania 19341 http://www.obj-sys.com Phone: (484) 875-9841 Toll-free: (877) 307-6855 (US only) Fax: (484) 875-9830 info@obj-sys.com |