[xsd-users] nillable="true"

Boris Kolpackov boris at codesynthesis.com
Fri Dec 30 08:48:32 EST 2011


Hi Brian,

B Hart <bhartsb at gmail.com> writes:

> I'm having trouble making sense of what's in ifc.zip.  Files are not
> commented and there are missing xsd files.

I believe the link to the .xsd files is in one of the earlier emails
in this thread.


> The readme's first XSD command line statement:
> xsd cxx-tree --options-file common.options --generate-xml-schema
> xml-schema.xsd
> This generates has definitions for all the schema built-in types into a
> separate .hxx.  I noted that the file I originally generated from my NEMSIS
> EMSDataSet.xsd had the includes for all .hxx files related to schema
> built-in types, and all the type defines for the C++ namespace
> "xml_schema".  When I regenerate EMSDataSet.hxx and EMSDataSet.cxx I see
> that the xml-schema includes and typedefs are no longer embedded, rather
> included indirectly via nillable-type.hxx.  So I'm assuming that you
> generated xml_schema stuff in a separate file just for good organization?

Not exactly. The nillable-type.hxx header needs some of the built-in
definitions (as you can see, it includes xml-schema.hxx).


> I now understand that ifc.options should contain just the XSD command line
> parameters the I would normally use for generating .hxx and .cxx from my
> NEMSIS schema. Since I don't use --generate-polymorphic or
> --generate-default-ctor I'm not sure whether in my case they're needed or
> not?

You need --generate-default-ctor for the *_nillable_type wrappers to work.


> Per the command line statements:
> xsd cxx-tree --options-file common.options --options-file ifc.options ex.xsd
> xsd cxx-tree --options-file common.options --options-file ifc.options
> --options-file ifc-custom.options --parts 10 IFC2X3.xsd
> 
> ex.xsd and IFC2X3.xsd are the missing files I mentioned.  I'm assuming that
> one of these would correspond to my EMSDataSet.xsd, but I'm not sure which
> one, or why there are two steps here instead of one???

That's how the IFC schemas are organized. You will need just one command
line (like for ex.xsd) if you have only one schema.


> So anyway, per my modified versions of two of the files in ifc.zip (I
> understand I didn't have to keep the same file names, but kept them the
> same while I'm trying to make sense of this):
> 
> ifc.options:
> --namespace-map http://www.nemsis.org=
> --root-element EMSDataSet
> #--generate-doxygen
> 
> --extern-xml-schema xml-schema.xsd
> --generate-default-ctor
> --hxx-prologue #include "nillable-type.hxx"
> 
> ifc-custom.options:
> 
> --custom-type DateTime=::simple_nillable_type<DateTime>

Please read the customization guide[1] to learn what the argument
of the --custom-type option means (I realize it is easier to ask me
to just give you the correct answer but as I mentioned in my previous
email we don't have the resources to write your application for you).
That option should be: 

--custom-type DateTime=::simple_nillable_type<DateTimeBase>/DateTimeBase

Also make sure that DateTime is a simple type. Otherwise use 
complex_nillable_type.

[1] http://wiki.codesynthesis.com/Tree/Customization_guide

Boris



More information about the xsd-users mailing list