[xsd-users] Too many anonymous types

Brian Young ARA/CFD byoung at ara.com
Thu May 22 10:11:36 EDT 2008


I am new to XSD, and trying to use this tool to generate some code for a
large schema (3+ MB). However the generated code overwhelms the VS2005
compiler with lots of issues. The main one I can't seem to get passed is
too many objects exported from a DLL/library, as mentioned here:
http://support.microsoft.com/kb/949945.

I tried various things like manually moving the parsing & serialization
code into a separate lib, to no avail.

So I dug in further and what I find is many, many types are being tagged
as anonymous which I didn't expect. The result is alot of duplication.
In some cases 30 or more separate class definitions for the same
data/type.

To illustrate the issue I have with the schema I am working with (which
I didnt develop), I have simplied the schema and pasted it below. If you
run it through the xsd tool, you'll see generated classes "complexType1"
and "complexType2" which is correct. But, you'll also see 2 classes
"anonType" and "anonType1" which are essentially the same. My goal is to
get a single "group1" class rather than 2 separate "anonType" &
"anonType1" classes.

I've tried many combinations of the command line args, but here are the
latest I'm using:

xsd.exe cxx-tree --output-dir  .\devTest --hxx-suffix .h --cxx-suffix
.cpp --ixx-suffix .i --fwd-suffix -fwd.hxx --namespace-map
http://www.w3.org/2001/XMLSchema=com::rdm::xml --generate-serialization
--generate-doxygen --generate-intellisense --export-symbol RDM_API
--hxx-prologue "#include \".\rdm_export.h\""  --show-sloc
--namespace-map =com::rdm 

Any suggestions? Is there a way to get the 'group ref' taken into
consideration when determining if a type is anonymous?

<?xml version="1.0" encoding="UTF-8" ?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified" attributeFormDefault="qualified" >

<xs:complexType name="complexType1" >
    <xs:annotation>
      <xs:documentation>complexType1</xs:documentation>
    </xs:annotation>
    <xs:all>
      <xs:annotation>
        <xs:documentation>A complex type</xs:documentation>
      </xs:annotation>
      <xs:element name="anonType" >
        <xs:annotation>
          <xs:documentation>anonType</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:group ref="group1" />
        </xs:complexType>
      </xs:element>
    </xs:all>
    <xs:attribute name="refID" type="xs:int" />
  </xs:complexType>
  <xs:complexType name="complexType2" >
    <xs:annotation>
      <xs:documentation>complexType2</xs:documentation>
    </xs:annotation>
    <xs:all>
      <xs:annotation>
        <xs:documentation>Another complex type</xs:documentation>
      </xs:annotation>
      <xs:element name="anonType" >
        <xs:annotation>
          <xs:documentation>anonType</xs:documentation>
        </xs:annotation>
        <xs:complexType>
          <xs:group ref="group1" />
        </xs:complexType>
      </xs:element>
    </xs:all>
    <xs:attribute name="refID" type="xs:int" />
  </xs:complexType>
    <xs:group name="group1" >
    <xs:annotation>
      <xs:documentation>A Group</xs:documentation>
    </xs:annotation>
    <xs:choice>
      <xs:annotation>
        <xs:documentation>Choice between some stuff</xs:documentation>
      </xs:annotation>
      <xs:element name="e1" type="element1" />
	  <xs:element name="e2" type="element2" />
    </xs:choice>
  </xs:group>
    <xs:complexType name="element1" >
    <xs:annotation>
      <xs:documentation>An element</xs:documentation>
    </xs:annotation>
    <xs:attribute name="refID" type="xs:int" >
      <xs:annotation>
        <xs:documentation>The ID</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
  <xs:complexType name="element2" >
    <xs:annotation>
      <xs:documentation>Another element</xs:documentation>
    </xs:annotation>
    <xs:attribute name="refID2" type="xs:int" >
      <xs:annotation>
        <xs:documentation>The ID</xs:documentation>
      </xs:annotation>
    </xs:attribute>
  </xs:complexType>
</xs:schema>

Thank you,
 Brian




More information about the xsd-users mailing list