[xsd-users] hxx file not including superclass type

Lane Wimberley techlane64 at gmail.com
Wed Feb 13 17:52:22 EST 2008


Sorry if this description is a bit on the long side.  I have an XSD file
that is including another file, which in turn includes one other.  The
generated header file for the first is not including the definition of a
class it uses as a superclass of another.

Here's the top-most file, zConfig.xsd ...

<xs:schema
  id="zebra.configuration.schema"
  version="1.0"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  targetNamespace="http://www.zebraimaging.com/ZebraConfig"
  xml:lang="en">

  <xs:include
    schemaLocation="SimpleParam.xsd" />

  <xs:include
    schemaLocation="ListParam.xsd" />

</xs:schema>

The SimpleParam.xsd contains, in part, the following ...

<xs:schema
  id="zebra.configuration.schema-simpleParam"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:zc="http://www.zebraimaging.com/ZebraConfig"
  targetNamespace="http://www.zebraimaging.com/ZebraConfig"
  xml:lang="en">

  <xs:include
    schemaLocation="zConfig-base.xsd" />

  <xs:complexType
    name="simpleParam_t"
    id="zebra.configuration.simpleParamType">

    <xs:complexContent>

      <xs:extension
        base="zc:configParam_t"> <!-- defined in zConfig-base.xsd -->

       <!-- some other stuff ... -->

      </xs:extension>

    </xs:complexContent>

  </xs:complexType>

  <xs:element
    name="simpleParam"
    type="zc:simpleParam_t"
    substitutionGroup="zc:configParam"
    id="zebra.configuration.simpleParam" />

</xs:schema>

And, finally, zConfig-base.xsd ...

<xs:schema
  id="zebra.configuration.schema-base"
  xmlns:xs="http://www.w3.org/2001/XMLSchema"
  xmlns:zc="http://www.zebraimaging.com/ZebraConfig"
  targetNamespace="http://www.zebraimaging.com/ZebraConfig"
  xml:lang="en">

  <xs:complexType
    name="configParam_t"
    id="zebra.configuration.ConfigParamType">

     <!-- stuff here -->

  </xs:complexType>

  <xs:element
    name="configParam"
    type="zc:configParam_t"
    abstract="true"
    id="zebra.configuration.configParam-abs"/>

  <xs:complexType
    name="section_t"
    id="zebra.configuration.sectionType">

    <xs:sequence>

      <xs:element
        ref="zc:configParam"
        maxOccurs="unbounded"
        id="zebra.configuration.configParam-ref" />

    </xs:sequence>

  </xs:complexType>

 <!-- a little more stuff here, including our top-level element definition
-->

</xs:schema>

Everything compiles with xsd just fine, but when I attempt to compile
zConfig.cxx, I get errors because in zConfig.hxx there is ...

  class simpleParam_t: public ::ZebraConfig::configParam_t

...but ::ZebraConfig::configParam_t is defined in zConfig-base.hxx, which is
not included.

Since I am still learning this stuff, I suspect that there is a more elegant
(or correct) way to do what I'm trying to do.  The difficulties arose when I
introduced the namespace (ZebraConfig), which I'm not sure I've done
correctly.  Or, maybe I need to manually include zConfig-base.hxx in a
prologue at xsd compile-time ... ?  Or, maybe I need to use the new "file
per type" option ... ?

BTW, here's what my xsd compile line looks like ...

xsd cxx-tree --generate-serialization --generate-doxygen
--generate-polymorphic --generate-inline --generate-ostream --root-element
config  --custom-type configParam_t=/configParam_base
--hxx-epilogue '#include "configParam-custom.hxx"'  zConfig-base.xsd

xsd cxx-tree --generate-serialization --generate-doxygen
--generate-polymorphic --generate-inline --generate-ostream --root-element
config  SimpleParam.xsd

xsd cxx-tree --generate-serialization --generate-doxygen
--generate-polymorphic --generate-inline --generate-ostream --root-element
config  zConfig.xsd




Sorry for any inconveniences.  I hope this is not so convoluted as to be a
pain.

-Lane Wimberley
Austin, TX



More information about the xsd-users mailing list