using xmlgen to generate instance from .xsd

Roy Jacob <[email protected]> Tue, 9 Sep 2003 06:01:51 -0700
Newsgroups gmane.comp.java.sun.xml.general
Message-ID <26826AA24153E64DB9B1E73679292CA30229A980@boxstermail.corp.ilumin.com>
Hi.

This is my first foray into the powerful world of XML schemas and
instances. I'm trying to generate an instance from the schema below
using the xmlgen tool.:

java -jar xmlgen.jar kycmeta.xsd -root
{http://www.isentry.com/kyc}/entityInstance

Unfortunately the generator chucks up a load of errors claiming that all
my types are nor simple "nor complex":

type "EntityType" is not a simple type nor a complex type
  18@file:/C:/dev/ilumin-uk/dva/xmlgen-20030225/kycmeta.xsd


I have valid and invalid examples of entityInstance that Visual
SlickEdit correctly (in)validates so I'm assuming that my schema is
valid. Passing the example to the generator makes no difference.

My ultimate goal is to be able generate new blank instances of various
types in the schema.

Any ideas?


<?xml version=3D"1.0" encoding=3D"ASCII"?>

<xsd:schema xmlns:xsd=3D"http://www.w3.org/2001/XMLSchema"
            xmlns:kyc=3D"http://www.isentry.com/kyc"
            targetNamespace=3D"http://www.isentry.com/kyc"
            elementFormDefault=3D"unqualified"
            attributeFormDefault=3D"unqualified">

  <xsd:annotation>
    <xsd:documentation xml:lang=3D"en">
    </xsd:documentation>
  </xsd:annotation>

<!-- =20
  <include
schemaLocation=3D"file:///C:/dev/ilumin-uk/dva/isentryapp/schema/xml/docm=
e
ta.xsd"/>
-->

  <xsd:element name=3D"entityInstance" type=3D"EntityType"/> =20
 =20
 =20
  <xsd:complexType name=3D"PersonName">
    <xsd:attribute name=3D"first" type=3D"xsd:string" use=3D"required"/>
    <xsd:attribute name=3D"middle" type=3D"xsd:string" =
use=3D"optional"/>
    <xsd:attribute name=3D"last" type=3D"xsd:string" use=3D"optional"/>
  </xsd:complexType>
 =20
  <xsd:complexType name=3D"PostalAddress">
    <xsd:sequence>
      <xsd:element name=3D"country" type=3D"xsd:string" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"state"   type=3D"xsd:string" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"city"    type=3D"xsd:string" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"street"  type=3D"xsd:string" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"name"    type=3D"xsd:string" minOccurs=3D"0"
maxOccurs=3D"1"/>
      <xsd:element name=3D"number"  type=3D"xsd:string" minOccurs=3D"0"
maxOccurs=3D"1"/>
      <xsd:element name=3D"postcode" type=3D"xsd:string" minOccurs=3D"1"
maxOccurs=3D"1"/>
    </xsd:sequence>
  </xsd:complexType>

  <xsd:complexType name=3D"Nation">
    <xsd:attribute name=3D"value" type=3D"xsd:string" use=3D"required"/>
  </xsd:complexType>
 =20
  <xsd:complexType name=3D"TelephoneNumber">
    <xsd:attribute name=3D"Number"  type=3D"xsd:string" =
use=3D"required"/>
    <xsd:attribute name=3D"Type" use=3D"required">
      <xsd:simpleType>
        <xsd:restriction base=3D"xsd:string">
          <xsd:enumeration value=3D"office"/>
          <xsd:enumeration value=3D"home"/>
          <xsd:enumeration value=3D"cell"/>
          <xsd:enumeration value=3D"fax"/>
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:attribute>
  </xsd:complexType>

 =20
  <!--=20
     =20
      Document Referance data type
     =20
  -->
  <xsd:complexType name=3D"KYCDocumentRef">
    <xsd:all>
      <xsd:element name=3D"docID" type=3D"xsd:decimal" minOccurs=3D"0"
maxOccurs=3D"1"/>
      <xsd:element name=3D"docType" type=3D"KYCDocumentType" =
minOccurs=3D"1"
maxOccurs=3D"1"/>
    </xsd:all>
  </xsd:complexType>
 =20


  <!--=20
     =20
      Inidividual Entity type=20
     =20
  -->
  <xsd:complexType name=3D"IndividualMeta">
    <xsd:sequence>
      <xsd:element name=3D"Name" type=3D"PersonName" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"Nationality" type=3D"Nation" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"TaxNationality" type=3D"Nation" =
minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"ResidentialAddress" type=3D"PostalAddress"
minOccurs=3D"1" maxOccurs=3D"1"/>
      <xsd:element name=3D"Phone" type=3D"TelephoneNumber" =
minOccurs=3D"1"
maxOccurs=3D"5"/>
      <xsd:element name=3D"Occupation" type=3D"xsd:string" =
minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"Employer" type=3D"xsd:string" minOccurs=3D"1"
maxOccurs=3D"1"/>
      <xsd:element name=3D"SignatureImage" type=3D"KYCDocumentRef"
minOccurs=3D"1" maxOccurs=3D"1"/>
      <xsd:element name=3D"ProofOfAddress" type=3D"KYCDocumentRef"
minOccurs=3D"1" maxOccurs=3D"1"/>
      <xsd:element name=3D"LetterOfReferance" type=3D"KYCDocumentRef"
minOccurs=3D"1" maxOccurs=3D"1"/>
      <xsd:element name=3D"ListExaminerProof" type=3D"KYCDocumentRef"
minOccurs=3D"0" maxOccurs=3D"1"/>
    </xsd:sequence>
  </xsd:complexType>
 =20
 =20
  <!--=20
     =20
      Corporate Entity type=20
     =20
  -->
  <xsd:complexType name=3D"CorporateMeta">
  </xsd:complexType>

  <!--=20
     =20
      Partnership Entity type=20
     =20
  -->
  <xsd:complexType name=3D"PartnershipMeta">
  </xsd:complexType>
 =20
  <!--=20
     =20
      Association Entity type=20
     =20
  -->
  <xsd:complexType name=3D"AssociationMeta">
  </xsd:complexType>
 =20
  <!--=20
     =20
      Trust Entity type=20
     =20
  -->
  <xsd:complexType name=3D"TrustMeta">
  </xsd:complexType>
 =20
 =20
  <!--=20
 =20
      KYC Document type enum.
      these MUST map to acutal types
 =20
  -->
  <xsd:simpleType name=3D"KYCDocumentType">
    <xsd:restriction base=3D"xsd:string">
      <xsd:enumeration value=3D"Signature"/>
      <xsd:enumeration value=3D"ProofOfID"/>
      <xsd:enumeration value=3D"EvidenceOfAddress"/>
      <xsd:enumeration value=3D"LetterOfReferance"/>
    </xsd:restriction>
  </xsd:simpleType>
 =20
  <!--=20
 =20
      KYC Signature type
 =20
  -->
  <xsd:complexType name=3D"Signature">
  </xsd:complexType>
 =20
  <!--=20
 =20
      KYC Proof of ID type
 =20
  -->
  <xsd:complexType name=3D"ProofOfID">
  </xsd:complexType>
 =20
  <!--=20
 =20
      KYC Evidence of address
 =20
  -->
  <xsd:complexType name=3D"EvidenceOfAddress">
  </xsd:complexType>
 =20
  <!--=20
 =20
      KYC Letter of Referance type
 =20
  -->
  <xsd:complexType name=3D"LetterOfReferance">
  </xsd:complexType>
 =20
 =20
 =20
  <!--=20
        All the possible entities listed and the type of meta they
derive from.
        This will be the=20
       =20
      Only allowed one of any of the lited types
  -->
  <xsd:complexType name=3D"EntityType">
    <xsd:choice>
      <xsd:element name=3D"NaturalPerson" type=3D"IndividualMeta"
minOccurs=3D"0" maxOccurs=3D"1"/>
      <xsd:element name=3D"Corporate" type=3D"CorporateMeta" =
minOccurs=3D"0"
maxOccurs=3D"1"/>
      <xsd:element name=3D"Partnership" type=3D"PartnershipMeta"
minOccurs=3D"0" maxOccurs=3D"1"/>
      <xsd:element name=3D"Association" type=3D"AssociationMeta"
minOccurs=3D"0" maxOccurs=3D"1"/>
      <xsd:element name=3D"TrustMeta" type=3D"TrustMeta" minOccurs=3D"0"
maxOccurs=3D"1"/>
    </xsd:choice>
  </xsd:complexType>


</xsd:schema>

-----------------------------------------------------
xml-interest: A list for discussing XML technologies in the Java Platform.
To post, mailto:[email protected]
Archives at: http://archives.java.sun.com/xml-interest.html
To unsubscribe, mailto:[email protected] the following message;
signoff xml-interest.