Keith
Take a look at the example for \Castor\src\examples\SourceGenerator\Invoice.xsd
for example a StateCodeType is initially declared as

<!-- State Code obviously not a valid state code-->
<!-- If the attribute will be used in iterators such as <xsd:sequence> then we need to declare this entity as a xsd:element --> <!--If the entity is already declared we can use a ref to the xsd:EntityType OR we can declare datatype as xsd:simpleType adding in name, type, minOccurs clauses--> <!--This declaration cannot be used a reference later since the declaration is a 'xsd:simpleType'-->
<xsd:simpleType name="stateCodeType">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[A-Z]{2}"/>
</xsd:restriction>
</xsd:simpleType>

<!-- A U.S. Zip Code is a wholly encapsulated xsd:element which can be resolved with a simple ref later on-->
<xsd:element name="zip-code">
<xsd:simpleType>
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9]{5}(-[0-9]{4})?"/>
</xsd:restriction>
</xsd:simpleType>
</xsd:element>

<!--Now we can use simpleType stateCodeType as they are predefined DataTypes..Notice the order of declaration is not significant -->

<xsd:sequence>
<!-- street address 1 *this is a string*-->
<xsd:element name="street1" type="xsd:string"/>

<!-- optional street address 2 this is a string with cardinality of 0-->
<xsd:element name="street2" type="xsd:string" minOccurs="0"/>

<!-- city- this is a string->
<xsd:element name="city" type="xsd:string"/>

<!-- state code Here is where we use our predefined DataType stateCodeType remember we MUST declare the xsd:element-->
<xsd:element name="state" type="stateCodeType"/>

<!-- zip-code This declaration references the earlier xsd:element datatype so we can resolve the datatype with ref ="XsdElementName" -->
<xsd:element ref="zip-code"/>

</xsd:sequence>
</xsd:complexType>


Either case will work in your scenario
HTH
Martin-
----- Original Message ----- From: "Keith P Hassen" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, June 10, 2005 10:25 AM
Subject: Re: [castor-user] binding for a simpleType.


Hi Martin,

Merci for your reply. :)  I probably didn't explain properly:

I want to generate Java source for an XSD that contains the snippets
included in my first email.  Currently, the SourceGenerator reports
some warnings about not supporting type "Foo", since "Foo" is
unsignedLong and in Java, there is no unsigned long.  So what I would
like to do is tell SourceGenerator to take any instances of "Foo" and
write them to the Java class as type long.  Does that make sense?


Regards,

-keith



Date:    Fri, 10 Jun 2005 10:07:21 -0400
From:    "Martin Gainty" <[EMAIL PROTECTED]>
To:      <[email protected]>
Subject: Re: [castor-user] binding for a simpleType.


Bonjour Keith
If you're using the 2001 spec I would utilise the datatypes defined at
http://www.w3.org/2001/XMLSchema
Bon Chance,
Martin-
Etats Unis
001-617-852-7822
----- Original Message ----- From: "Keith P Hassen" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Friday, June 10, 2005 2:08 AM
Subject: [castor-user] binding for a simpleType.


> Hi,
>
> I am fairly new to castor and am just curious if there is a way
> (using the binding XML file) to get castor to recognize the
> following:
>
> <xs:simpleType name="Foo">
>    <xs:restriction base="xs:unsignedLong"/>
> </xs:simpleType>
>
> as actually being of type "long", not type "Foo".  I make use of
> that type in another declaration with a structure like this:
>
> <xs:complexType name="FooBar">
>    <xs:sequence>
>        <xs:element name="MyFoo" type="Foo"/>
>    </xs:sequence>
> </xs:complexType>
>
>
> I'm just a little fuzzy on how one might specify that in the castor
> binding file.  Any guidance would be appreciated.
>
>
> Regards,
>
> -k
>
> -- >
> -------------------------------------------------
> If you wish to unsubscribe from this list, please
> send an empty message to the following address:
>
> [EMAIL PROTECTED]
> -------------------------------------------------
>
>

-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------


-------------------------------------------------
If you wish to unsubscribe from this list, please
send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------



-------------------------------------------------
If you wish to unsubscribe from this list, please send an empty message to the following address:

[EMAIL PROTECTED]
-------------------------------------------------

Reply via email to