Hi.
I am using castor-0.9.3.19-xml to compile a schema using SourceGenerator.
I have a schema A that imports another schema B. In A I have a complex type
"extension" that is a restriction of a complexType baseT. baseT is from a
different namespace since it was imported (schema are show at the end).
SourcGenerator fails with this error:
the simple type 'baseT' is not a built-in type as defined in XML Schema
specification.
Looking at the code I think I see where the problem lies.
Here is the calling sequence:
The ComplexContentRestrictionUnmarshaller constructor calls:
_schema.getType("qb:baseT")
which calls
getSimpleType("qb:baseT");
which calls
Schema schema = getImportedSchema(ns);
schema.getSimpleType(canonicalName);
Where ns is "http://www.q.com/XMLSchema/BIM" and canonicalName is "baseT".
Now in getSimpleType (now for the imported Schema object (b.xsd)) name has
no namespace prefix so the namespace is assumed (in this case
"http://www.w3.org/2001/XMLSchema") and the call fails because no
http://www.w3.org/2001/XMLSchema:baseT type is known.
Doing this in getSimpleType solves the problem, but I am not sure it's the
right
thing to do:
Schema schema = getImportedSchema(ns);
schema.getSimpleType(name); // look up the fully qualified name (with
prefix)
How can this issue be fixed?
Thanks.
Florian Kirchhoff
==== a.xsd ====
<?xml version = "1.0" encoding = "UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.q.com/XMLSchema"
xmlns:qb="http://www.q.com/XMLSchema/BIM"
xmlns:qw="http://www.q.com/XMLSchema"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault = "qualified">
<import namespace="http://www.q.com/XMLSchema/BIM" schemaLocation =
"b.xsd"/>
<complexType name="extension">
<complexContent>
<restriction base = "qb:baseT">
<sequence>
<element name = "Code" minOccurs = "0">
<simpleType>
<restriction base = "string">
<enumeration value = "GdCust"/>
</restriction>
</simpleType>
</element>
</sequence>
</restriction>
</complexContent>
</complexType>
<element name = "foo" type="qw:extension"/>
</schema>
=== b.xsd ===
<?xml version = "1.0" encoding = "UTF-8"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://www.q.com/XMLSchema/BIM"
xmlns:qb="http://www.q.com/XMLSchema/BIM"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
elementFormDefault = "qualified">
<complexType name="baseT">
<sequence>
<element name="Code" type = "string" minOccurs = "0"/>
</sequence>
</complexType>
</schema>
> -----Original Message-----
> From: Keith Visco [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 06, 2002 1:27 PM
> To: [EMAIL PROTECTED]
> Subject: Re: [castor-dev] SourceGenerator does not recognize
> elements from another schema?
>
>
>
> Based on your example schema it looks like you are having a
> default namespace crisis.
>
> You'll need to prefix "IDType" with "ns1", as such "ns1:IDType".
>
> Or you can change the default namespace to
> "http://multschema1.com" and declare a prefix for the XML
> Schema namespace as such:
>
> <xsd:schema targetNamespace="http://www.multschema1.com/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns="http://www.multschema1.com/">
> <xsd:simpleType name="IDType">
> <xsd:restriction base="xsd:string"/>
> </xsd:simpleType>
> </xsd:schema>
>
>
> The fact that it worked before in version 0.9.3.9, is
> probably a bug in that version.
>
> --Keith
>
>
> Tahura Chaudhry wrote:
> >
> > I've been using castor for the last few months to generate
> Java source
> > from schema files. I recently updated to the latest
> release version
> > Castor 0.9.3.19 . Surprisingly the source generator failed to
> > generate the source files for the schemas. I have not modified the
> > schema files and suspect that this may be due to recent
> code fixes or
> > enhancements to Castor. I have attached below the two
> sample schemas the error messages as outputted by the
> > source generator. Can someone please tell me why this may
> be happening and
> > if there is a workaround. Thanks.
> >
> > -------------------
> > SCHEMA FILE 1::
> > <schema targetNamespace="http://www.multschema1.com/"
> > xmlns="http://www.w3.org/2001/XMLSchema"
> > xmlns:ns1="http://www.multschema1.com/">
> > <simpleType name="IDType">
> > <restriction base="string" />
> > </simpleType>
> > </schema>
> >
> > SCHEMA FILE 2::
> > <schema targetNamespace="http://www.multschema2.com/"
> > xmlns="http://www.w3.org/2001/XMLSchema"
> > xmlns:ns1="http://www.multschema1.com/"
> > xmlns:ns2="http://www.multschema2.com/">
> > <import namespace="http://www.multschema1.com/"
> > schemaLocation="multSchema1.xsd" />
> > <element name="someElement" type="ns2:someElementType"/>
> > <complexType name="someElementType">
> > <attribute name="ID" type="ns1:IDType"
> use="required" />
> > </complexType>
> > </schema>
> >
> > ERROR ::
> > -- Suppressing non fatal warnings.
> >
> > Warning: Do not forget to generate source code for the following
> > imported
> > schema: d:/schemas/others/multSchema1.xsd
> > Exception in thread "main" java.lang.IllegalArgumentException:
> > getSimpleType: the simple type 'IDType' is not a built-in t
> > ype as defined in XML Schema specification.
> > at
> > org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:838)
> > at
> > org.exolab.castor.xml.schema.Schema.getSimpleType(Schema.java:859)
> > at
> >
> org.exolab.castor.xml.schema.SimpleTypeReference.resolveTypeRe
> ference(Simple
> > TypeReference.java:102)
> > at
> >
> org.exolab.castor.xml.schema.SimpleTypeReference.getType(Simpl
> eTypeReference
> > .java:92)
> > at
> >
> org.exolab.castor.xml.schema.AttributeDecl.getSimpleType(Attri
> buteDecl.java:
> > 223)
> > at
> >
> org.exolab.castor.builder.SourceFactory.processAttributes(Sour
> ceFactory.java
> > , Compiled Code)
> > at
> >
> org.exolab.castor.builder.SourceFactory.processComplexType(Sou
> rceFactory.jav
> > a:1355)
> > at
> >
> org.exolab.castor.builder.SourceFactory.createSourceCode(Sourc
> eFactory.java:
> > 444)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.processComplexType(S
> ourceGenerator
> > .java, Compiled Code)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.createClasses(Source
> Generator.java
> > , Compiled Code)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.createClasses(Source
> Generator.java
> > , Compiled Code)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.generateSource(Sourc
> eGenerator.jav
> > a:366)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.generateSource(Sourc
> eGenerator.jav
> > a:424)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.generateSource(Sourc
> eGenerator.jav
> > a:453)
> > at
> >
> org.exolab.castor.builder.SourceGenerator.main(SourceGenerator
> .java:696)
> >
> >
> >
> >
> ----------------------------------------------------------------------
> > -------------------------------------------
> > The information contained in this message is confidential
> and is intended
> > for the addressee(s) only. If you have received this
> message in error or
> > there are any problems please notify the originator
> immediately. The
> > unauthorised use, disclosure, copying or alteration of this
> message is
> > strictly forbidden. Baltimore Technologies plc will not be
> liable for
> > direct, special, indirect or consequential damages arising
> from alteration of the
> > contents of this message by a third party or as a result of
> any virus being
> > passed on.
> >
> > This footnote confirms that this email message has been swept for
> > Content Security threats, including computer viruses.
> >
> > http://www.baltimore.com
> >
> >
> > This footnote confirms that this email message has been swept by
> > Baltimore MIMEsweeper for Content Security threats,
> including computer
> > viruses.
> >
> > -----------------------------------------------------------
> > If you wish to unsubscribe from this mailing, send mail to
> > [EMAIL PROTECTED] with a subject of:
> > unsubscribe castor-dev
>
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
> unsubscribe castor-dev
>
-----------------------------------------------------------
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
unsubscribe castor-dev