Great, thanks for taking a look at that. I realize that the SchemaWriter is
only experimental and I wouldn't have written in, except that I think the
namespace resolution in XMLType may be important in other areas. Definately
do not waste your time on the Writer on my behalf, I will do any changes
that I need. After I have done all of my own changes to the schema writer I
will definately submit them to you guys. In particular I am going to try to
add support for xsd:import.

Thanks

matt

-----Original Message-----
From: Keith Visco [mailto:[EMAIL PROTECTED]]
Sent: Wednesday, August 22, 2001 1:28 PM
To: [EMAIL PROTECTED]
Subject: Re: [castor-dev] Namespace in XMLType




Hi Matt,

I'll take a look at upgrading the SchemaWriter and adding the additional
namespace resolution you mentioned below. Keep in mind however that the
SchemaWriter is currently not supported. I only hacked it together for
testing purposes, which is why you need to explicitly enable it's usage.
:-)

Thanks,

--Keith


Matt Small wrote:
> 
> I think that there needs to be some way to associate a namespace reference
> to an XMLType object. In particular, when you construct a Schema and
assign
> a TypeReference to an element such as "xsd:string", if you need to get the
> type back from the ElementDecl, the namespace reference is stripped and
you
> just get a StringType object.  There is no way to get the namespace
> reference from the TypeReference because this class is package private. It
> also seems like I should be able to create complex types and associate
them
> to particular namespaces.
> 
> This problem actually shows itself in the SchemaWriter class.
> 
> If I load the following schema
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> targetNamespace="http://www.test.com/test/test";>
>     <xsd:element name="test" type="testType"/>
>     <xsd:complexType name="testType">
>         <xsd:sequence>
>             <xsd:element name="test1" type="xsd:string"/>
>             <xsd:element name="test2" type="xsd:string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
> 
> And then use SchemaWriter to write it back it gets written as:
> 
> <?xml version="1.0"?>
> <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema";
> targetNS="http://www.test.com/test/test";>
>     <xsd:element name="test" type="testType"/>
>     <xsd:complexType name="testType">
>         <xsd:sequence>
>             <xsd:element name="test1" type="string"/>
>             <xsd:element name="test2" type="string"/>
>         </xsd:sequence>
>     </xsd:complexType>
> </xsd:schema>
> 
> Note that if you then try to reload the generated schema, Castor will give
> the error "getSimpleType: the simple type 'string' has not been declared
in
> XML Schema namespace."
> 
> Has anyone else run into this problem? Does anybody know of any good
> workarounds? I had to hack schema writer and use the isBuiltInType method
to
> work around this:
> 
>                         if (type instanceof SimpleType &&
> ((SimpleType)type).isBuiltInType()){
>                                 if (type.getName() != null) {
>                                         //System.out.println("type name
> isn't null, it's: " + type.getName());
>                                         _atts.addAttribute("type", null,
> "xsd:"+type.getName());
>                                 }else
>                                         hasAnonymousType = true;
>                         }else{
>                                 //System.out.println("Its not a reference,
> type is " + type);
>                                 if (type.getName() != null) {
>                                         //System.out.println("type name
> isn't null, it's: " + type.getName());
>                                         _atts.addAttribute("type", null,
> type.getName());
>                                 }else
>                                         hasAnonymousType = true;
>                         }
> 
> also, SchemaWriter should be updated to print "targetNamespace" not
> "targetNS"
> 
> -----------------------------------------------------------
> 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

Reply via email to