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

Reply via email to