Fausto,
can you please create a new Jira issue at
http://jira.codehaus.org/browse/CASTOR
and attach a working JUnit test case that I can use to replay your
problem ? I am not sure whether we are looking at a bug or not, but I'd
need something to 'play with' to get an educated opinion.
Regards
Werner
Fausto wrote:
I am having a problem while reading a schema which includes other schema.
I cannot send the schema information due to business policies, but I can
create samples.
My schema goes like this:
On SchemaOne.xsd:
<xs:schema xmlns:careq="http://my.schema.SchemaOne.xsd
<http://my.schema.schemaone.xsd/>"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
targetNamespace="http://my.schema.one <http://my.schema.one/>"
elementFormDefault="unqualified
" attributeFormDefault="unqualified" version="1.0">
<xs:include schemaLocation="SchemaTwo.xsd"/>
On SchemaTwo.xsd:
<xs:schema xmlns:mv="http://my.schema.SchemaTwo.xsd
<http://my.schema.schematwo.xsd/>"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="unqualified" attributeFormDefault="unqualified"
version="1.0">
(...)
<xs:simpleType name="MySimpleType">
<xs:annotation>
<xs:documentation>------------------</xs:documentation>
<xs:documentation>------------------</xs:documentation>
</xs:annotation>
<xs:restriction base="xs:string">
<xs:maxLength value="100"/>
</xs:restriction>
</xs:simpleType>
(...)
SchemaOne.xsd does not use the MySimpleType.
When I try the method read() from a SchemaReader, I get this error:
org.exolab.castor.xml.schema.SchemaException: An error occured at line:
53: getSimpleType: the simple type 'MySimpleType' is not a built-in type
as defined in XML Schema specification.
at
org.exolab.castor.xml.schema.reader.ImportUnmarshaller.<init>(ImportUnmarshaller.java:203)
at
org.exolab.castor.xml.schema.reader.SchemaUnmarshaller.startElement(SchemaUnmarshaller.java:519)
at
org.exolab.castor.xml.schema.reader.Sax2ComponentReader.startElement(Sax2ComponentReader.java:255)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at
org.exolab.castor.xml.schema.reader.SchemaReader.read(SchemaReader.java:248)
( front-end stack trace )
Caused by: org.exolab.castor.xml.schema.SchemaException: An error
occured at line: 53: getSimpleType: the simple type
'ElectronicAddressString' is not a built-in type as defined in XML
Schema specification.
at
org.exolab.castor.xml.schema.reader.Sax2ComponentReader.startElement(Sax2ComponentReader.java:258)
at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown
Source)
at
org.apache.xerces.parsers.AbstractXMLDocumentParser.emptyElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanStartElement(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown
Source)
at
org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown
Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
at
org.exolab.castor.xml.schema.reader.ImportUnmarshaller.<init>(ImportUnmarshaller.java:197)
... 41 more
I've looked at internet and found something like "this happens when the
schema namespace is the same as http://www.w3.org/2001/XMLSchema", but
this is not what happens.
However, the SchemaTwo.xsd does not have a targetNamespace defined and I
was thinking that if this could be a bug.
I do not have access to the entire codebase, but I could find this on
fisheye.codhaus.org <http://fisheye.codhaus.org/>:
SimpleType result = null;
if (ns == null) {
//-- first check user-defined types
result = (SimpleType)_simpleTypes.get(name);
if (result != null) {
//-- resolve deferred type if necessary
if (result.getType() != result) {
//-- can result.getType ever return null?
//-- We can check, just in case.
if (result.getType() != null) {
result = (SimpleType)result.getType();
result.setParent(this);
_simpleTypes.put(name, result);
}
}
}
//-- otherwise try built-in types
else {
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);
}
}
}
else if (ns.equals(_schemaNamespace)) {
result= simpleTypesFactory.getBuiltInType(canonicalName);
* if (result == null) {*
* String err = "getSimpleType: the simple type
'"+canonicalName+
"' is not a built-in type as defined in
XML Schema specification.";*
throw new IllegalArgumentException(err);
}
}
There might be a bug with the xsd having no namespace? In what cases the
result is null?
Do you need more information?
I need to solve this as soon as I can, because even setting
setValidation(false); on the reader does not work.
Thank you,
Fausto.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email