Hi Dave,
Thanks for your patch (included below). Your patch, however, assumes
that the prefix will be the same in both schema, which isn't necessarily
true...
I mentioned in a previous posting that I will add a new method as such:
Schema#getSimpleType(local_name, namespace)
This will prevent the need from using the prefix.
Thanks,
--Keith
diff -u -r1.50 Schema.java
--- src/main/org/exolab/castor/xml/schema/Schema.java 5 May 2002
01:07:00 -0000 1.50
+++ src/main/org/exolab/castor/xml/schema/Schema.java 31 May 2002
14:55:30 -0000
@@ -856,7 +856,11 @@
else {
Schema schema = getImportedSchema(ns);
if (schema!=null)
- result = schema.getSimpleType(canonicalName);
+ //result = schema.getSimpleType(canonicalName);
+ // Modified by Dave Carlson.
+ // The canonicalName (without prefix) will look for XSD
built-in
+ // types when XSD is the default ns.
+ result = schema.getSimpleType(name);
}
Dave Carlson wrote:
>
> I attached a patch file that fixed this problem for me. It also fixes a
> second problem where Castor does not handle the case were a complexType
> extends xs:anyType.
>
> This diff is based on a CVS version of Schema.java from 2 weeks ago. I
> planned to do a bit more testing then submit this to Bugzilla. But here it
> is until then.
>
> Regards,
> Dave Carlson
>
> ----- Original Message -----
> From: "Perryn Fowler" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Friday, June 14, 2002 2:37 AM
> Subject: [castor-dev] Status of imported schema's with Castor Source
> Generator?
>
> >
> > I have recently run into a problem when trying to generate Java classes
> from
> > a schema
> > which uses <xsd:import> to import another schema containing components
> from
> > another namespace.
> >
> > Basically Castor doesnt seem to recognize that these components are
> imported
> > when they are referenced
> > and complains that they are not built-in types.
> >
> > I have seen a number of other post to this list about this problem
> recently
> > and was wondering what the status
> > of this problem is? Is there a bug raised for it? This is unfortunately a
> > showstopper for us wrt Castor so
> > Im looking for a handle on whats happening with it.
> >
> > Cheers
> > Perryn
> >
> >
> > For reference I have produced the problem using the 'report' example from
> > the W3C Schema Primer:
> >
> > In ipo.xsd:
> > <schema targetNamespace="http://www.example.com/IPO"
> > xmlns="http://www.w3.org/2001/XMLSchema"
> > xmlns:ipo="http://www.example.com/IPO">
> >
> > <!-- SNIP -->
> >
> > <simpleType name="SKU">
> > <restriction base="string">
> > <pattern value="\d{3}-[A-Z]{2}"/>
> > </restriction>
> > </simpleType>
> >
> > </schema>
> >
> >
> > In report.xsd:
> > <schema targetNamespace="http://www.example.com/Report"
> > xmlns="http://www.w3.org/2001/XMLSchema"
> > xmlns:r="http://www.example.com/Report"
> > xmlns:xipo="http://www.example.com/IPO"
> > elementFormDefault="qualified">
> >
> > <import schemaLocation="ipo.xsd" namespace="http://www.example.com/IPO" />
> >
> > <!-- SNIP -->
> >
> > <complexType name="RegionsType">
> > <sequence>
> > <element name="zip" maxOccurs="unbounded">
> > <complexType>
> > <sequence>
> > <element name="part" maxOccurs="unbounded">
> > <complexType>
> > <attribute name="number" type="xipo:SKU"/> <---------
> >
> > <attribute name="quantity" type="positiveInteger"/>
> > </complexType>
> > </element>
> > </sequence>
> > <attribute name="code" type="positiveInteger"/>
> > </complexType>
> > </element>
> > </sequence>
> > </complexType>
> > </schema>
> >
> > then an attempt to generate from report.xsd produces:
> >
> > Exception in thread "main" java.lang.IllegalArgumentException:
> > getSimpleType: the simple type 'SKU' is not a built-in type as defined in
> > XML Schema specification.
> >
>
> ------------------------------------------------------------------------
> Name: Schema.java patch.txt
> Schema.java patch.txt Type: Plain Text (text/plain)
> Encoding: quoted-printable
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev