SimpleType Not Being Created

Jan 28, 2011 at 4:48 PM
Edited Jan 28, 2011 at 5:08 PM

First off, Great project and appreciate all the work and effort – this tool blows the doors off XSD.exe!

I’m new to XSD schema’s but have a project that I’m lost on – im 99% done and my complex types were easy, but have a few simpletype fields left to fill and I’m stuck :(

I've chopped a huge xsd to the following example

<?xml version="1.0" encoding="utf-8"?>
<xs:schema
attributeFormDefault="unqualified"
elementFormDefault="qualified"
xmlns:GCCSCargoImp="http://www.champ.aero/GCCS/CargoXML"
targetNamespace="http://www.champ.aero/GCCS/CargoXML"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
version="3.0"
>

  <xs:complexType name="AWBIssueDetails">
    <xs:choice>
      <xs:element name="Place" type="GCCSCargoImp:Place"/>
      <xs:element name="Amount" type="GCCSCargoImp:Amount"/>
    </xs:choice>
    <xs:attribute name="Weight" type="GCCSCargoImp:Weight" use="required"/>
  </xs:complexType>

  <xs:simpleType name="Weight">
    <xs:restriction base="GCCSCargoImp:Decimal">
      <xs:minInclusive value="0"/>
      <xs:totalDigits value="7"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Place">
    <xs:restriction base="GCCSCargoImp:Text">
      <xs:maxLength value="17"/>
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Amount">
    <xs:restriction base="GCCSCargoImp:Decimal">
    </xs:restriction>
  </xs:simpleType>

  <xs:simpleType name="Decimal">
    <xs:restriction base="xs:decimal"/>
  </xs:simpleType>

  <xs:simpleType name="Text">
    <xs:restriction base="xs:string">
    <xs:pattern value="[A-Z0-9\-\. ]*"/>
    </xs:restriction>
  </xs:simpleType>

</xs:schema>

None of the Simple types are created so I can't cast them to the <choice> of AWBIssueDetails?

ie

AWBIssueDetails foo = new AWBIssueDetails()

Place bar  = new Place();  <--- Error Place in not a type :(
bar=”New York”;
foo.item = bar;

-----------------------------------------------------------------------

Other Weird thing - If the <choice> members were both type="GCCSCargoImp:Amount"/>

  <xs:complexType name="AWBIssueDetails">
    <xs:choice>
      <xs:element name="Place" type="GCCSCargoImp:Amount"/>
      <xs:element name="Amount" type="GCCSCargoImp:Amount"/>
    </xs:choice>
    <xs:attribute name="Weight" type="GCCSCargoImp:Weight" use="required"/>
  </xs:complexType>

Then An enum is generated?

    public enum ItemChoiceType
    {   Amount,
        Place,
    }
    public ItemChoiceType ItemElementName
    {
      get
      {  return this.itemElementNameField;  }
      set
      { this.itemElementNameField = value; }
    }
Not sure what this is for since Amount and Place are still not typed?
As I said, Im new new to XSD's, Any suggestions are greatly appreciated

Many Thanks in advance!

Regards,
Mike Pisano

 

Oct 2, 2012 at 9:31 PM

Hi Mike

i have the same problem

the following XSD Type

  <xsd:simpleType name="FinancialAmt">
    <xsd:restriction base="xsd:string">
      <xsd:pattern value="[0-9.\-]{0,18}" />
    </xsd:restriction>
  </xsd:simpleType>

When creating the code it would simply convert the variable to type string without any validation code

have you been able to solve this problem?

Oct 2, 2012 at 11:41 PM

 

No, I believe I handled it in my wrapper class around the one XSD2CODE created and re validated \ TypeConverted manually in the get\set routines.

Luckily, most of mine were strings and I believe a just wrote a function to check the length and raise an error, similar with the decimals and integers.

If you come up with a better solution let me know

Regards,

Mike

Nov 1, 2012 at 2:47 PM

I am also encountering a similar issue. Thanks for asking the question! Maybe someone will come up with an answer.