Hi Florian,

> 
> I have been using Castor SourceGenerator for a while now and have find
it a
> great tool.

Thanks ;)

> 
> However I have encountered the following problem when using
SourceGenerator
> to
> generate code from the following schema (BTW: I have no control over
the
> schema
> I *must* use it as is):

Humm, this is not really a good design to bound the XML Schema namespace
to the default namespace and to a prefix, anyway it is allowed so it
should work.

> 
> <schema xmlns="http://www.w3.org/2001/XMLSchema";
>   targetNamespace="http://www.qwest.com/XMLSchema";
>   xmlns:qw="http://www.qwest.com/XMLSchema";
>   xmlns:xsd="http://www.w3.org/2001/XMLSchema";
>   elementFormDefault="qualified"
>   attributeFormDefault="unqualified">
> <complexType name="IdentificationT">
>  <simpleContent>
>   <restriction base="string">
>          <enumeration value="GenericId" />
>          <enumeration value="KeyCode" />
>          <enumeration value="CompositeKey" />
>   </restriction>
> </simpleContent>
> </complexType>
> </schema>
> 
> I get the following error:
> 
> java.lang.IllegalArgumentException: getSimpleType: the simple type
'string'
> has not been declared in XML Schema namespace.
> 
> The error can be lifted if I use a namespace prefix in
type="xsd:string" or
> if I remove the xsd namespace declaration in the <schema > element.
> 
> I traced this error back to the getSimpleType method in the Schema
class:
> 
>     result= simpleTypesFactory.getBuiltInType(name);
>     //if we have a built-in type not declared in the good namespace ->
> Exception
>     if ( (result != null) &&
(_namespaces.contains(DEFAULT_SCHEMA_NS))) {
>        String err = "getSimpleType: the simple type '"+name+
>                     "' has not been declared in XML Schema
namespace.";
>        throw new IllegalArgumentException(err);
>     }
> 
> I don't understand the reason behind this if statement. It doesn't
seem
> right. Even
> if the NS declaration isn't needed it's allowed from the XML schema
specs
> and
> hence shouldn't break anything. Am I missing something?. 

According to XML Schema Recommendation part 2: the built-in datatypes
must be in one of the following namespaces:

http://www.w3.org/2001/XMLSchema

or

http://www.w3.org/2001/XMLSchema-datatypes for applications that just
want to use XML Schema types.

That's mean that 'string' must be bound to one those two namespaces and
it is...the bug is in Castor. I've checked in a fix that allow reading
your schema.

Moreover your schema is not correct: a complexType cannot be the
restriction of a simpleType, this schema is invalid.


Arnaud

----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-dev

Reply via email to