Title: Question on Castor's Source Generator tool.

Hi Arnaud,

 

Thank you for your quick response. Yes, I did use the CVS version. I think my problem was because I used the source code instead of the jar file.  After I change that, it works.  

 

But when I try to compile them, it generated the message as follows:

Note: Some input files use or override a deprecated API. Is that because my XML schema is not the correct version? By the way, the input file I am using now is the invoice.xsd which comes up with Castor’s CVS version. Please see the attached invoice.xsd also. Thanks,

 

Yan.

 

 

-----Original Message-----
From: Arnaud Blandin [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 01, 2001 1:24 PM
To:
[EMAIL PROTECTED]
Subject: Re: [castor-dev] Question on Castor's Source Generator tool.

 

Hi Yan,

 

Are you using the CVS version?

 

Arnaud

-----Original Message-----
From:
Yan [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 01, 2001 7:11 AM
To:
[EMAIL PROTECTED]
Subject: [castor-dev] Question on Castor's Source Generator tool.

Hi,

I spend some time on Castor’s Source Generator. I think it is really a very good tool which does save resources and efforts for our company. But I came across some problems when I try to use Source Generator to generate classes from an XML schema.

The problem is when I use the following schema and try to generate according classes; it does not provide classes for simple type element. Therefore all of those generated classes can not be compiled.

The schema is as follows:

<?xml version="1.0" encoding="UTF-8"?>

<schema targetNamespace="http://www.altova.com/IPO" xmlns="http://www.w3.org/2001/XMLSchema" xmlns:ipo="http://www.altova.com/IPO" elementFormDefault="unqualified" attributeFormDefault="unqualified">

        <annotation>

                <documentation>

   Addresses for International Purchase order schema

   Copyright 2000 Example.com. All rights reserved.

  </documentation>

        </annotation>

        <complexType name="Address">

                <sequence>

                        <element name="name" type="string" minOccurs="0"/>

                        <element name="street" type="string"/>

                        <element name="city" type="string"/>

                </sequence>

        </complexType> ……

The generated classes are:

public abstract class Address implements java.io.Serializable {

    private Name _name;

 

    private Street _street;

    private City _city;

      …      … 

 }

Since it did not generate Name, Street and City classes, I can not compile the Address class. But I did see some examples from Castor’s User Guideline for Source Generator. It seems it can map simple type in XML schema to Java types. Could you tell me how to solve it? Thank you very much.

Yan.

 

<?xml version="1.0"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"; xmlns="http://castor.exolab.org/Test/Invoice"; targetNamespace="http://castor.exolab.org/Test/Invoice";>
	<xsd:annotation>
		<xsd:documentation>
         This is a test XML Schema for Castor XML.
      </xsd:documentation>
	</xsd:annotation>
	<!--
       A simple representation of an invoice. This is simply an example
       and not meant to be an exact or even complete representation of an invoice.
     -->
	<xsd:element name="invoice">
		<xsd:annotation>
			<xsd:documentation>
             A simple representation of an invoice
         </xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="ship-to">
					<xsd:complexType>
						<xsd:group ref="customer"/>
					</xsd:complexType>
				</xsd:element>
				<xsd:element ref="item" maxOccurs="unbounded" minOccurs="1"/>
				<xsd:element ref="shipping-method"/>
				<xsd:element ref="shipping-date"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<!-- Description of a customer -->
	<xsd:group name="customer">
		<xsd:sequence>
			<xsd:element name="name" type="xsd:string"/>
			<xsd:element ref="address"/>
			<xsd:element name="phone" type="TelephoneNumberType"/>
		</xsd:sequence>
	</xsd:group>
	<!-- Description of an item -->
	<xsd:element name="item">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="Quantity" type="xsd:integer" minOccurs="1" maxOccurs="1"/>
				<xsd:element name="Price" type="PriceType" minOccurs="1" maxOccurs="1"/>
			</xsd:sequence>
			<xsd:attributeGroup ref="ItemAttributes"/>
		</xsd:complexType>
	</xsd:element>
	<!-- Shipping Method -->
	<xsd:element name="shipping-method">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="carrier" type="xsd:string"/>
				<xsd:element name="option" type="xsd:string"/>
				<xsd:element name="estimated-delivery" type="xsd:duration"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<!-- Shipping date -->
	<xsd:element name="shipping-date">
		<xsd:complexType>
			<xsd:sequence>
				<xsd:element name="date" type="xsd:date"/>
				<xsd:element name="time" type="xsd:time"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<!-- A simple U.S. based Address structure -->
	<xsd:element name="address">
		<xsd:annotation>
			<xsd:documentation>
            Represents a U.S. Address
         </xsd:documentation>
		</xsd:annotation>
		<xsd:complexType>
			<xsd:sequence>
				<!-- street address 1 -->
				<xsd:element name="street1" type="xsd:string"/>
				<!-- optional street address 2 -->
				<xsd:element name="street2" type="xsd:string" minOccurs="0"/>
				<!-- city-->
				<xsd:element name="city" type="xsd:string"/>
				<!-- state code -->
				<xsd:element name="state" type="stateCodeType"/>
				<!-- zip-code -->
				<xsd:element ref="zip-code"/>
			</xsd:sequence>
		</xsd:complexType>
	</xsd:element>
	<!-- A U.S. Zip Code -->
	<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>
	<!-- State Code
        obviously not a valid state code....but this is just
        an example and I don't feel like creating all the valid
        ones.
    -->
	<xsd:simpleType name="stateCodeType">
		<xsd:restriction base="xsd:string">
			<xsd:pattern value="[A-Z]{2}"/>
		</xsd:restriction>
	</xsd:simpleType>
	<!-- Telephone Number -->
	<xsd:simpleType name="TelephoneNumberType">
		<xsd:restriction base="xsd:string">
			<xsd:length value="12"/>
			<xsd:pattern value="[0-9]{3}-[0-9]{3}-[0-9]{4}"/>
		</xsd:restriction>
	</xsd:simpleType>
	<!-- Cool price type -->
	<xsd:simpleType name="PriceType">
		<xsd:restriction base="xsd:decimal">
			<xsd:fractionDigits value="2"/>
			<xsd:totalDigits value="5"/>
			<xsd:minInclusive value="1"/>
			<xsd:maxInclusive value="100"/>
		</xsd:restriction>
	</xsd:simpleType>
	<!-- The attributes for an Item -->
	<xsd:attributeGroup name="ItemAttributes">
		<xsd:attribute name="Id" type="xsd:ID" />
		<xsd:attribute name="InStock" type="xsd:boolean" default="false"/>
		<xsd:attribute name="Category" type="xsd:string" use="required"/>
	</xsd:attributeGroup>
</xsd:schema>


Reply via email to