Details
-
Type:
Bug
-
Status:
Open
-
Priority:
Major
-
Resolution: Unresolved
-
Affects Version/s: 0.9.5.4
-
Fix Version/s: None
-
Component/s: XML code generator
-
Labels:None
-
Environment:Operating System: Linux
Platform: PC
-
Bugzilla Id:1833
-
Number of attachments :
Description
I was having trouble generating castor classes based on an xsd that imported
other xsds and namespaces. Originally I had:
<xs:schema ...>
<import namespace="http://namespace1" schemaLocation="http://www/schema.xsd"
and then down where i wanted to use an element from namespace1, i had:
<xs:element xmlns="http://namespace1" ref="element_from_namespace1"/>
But Castor would bork out and say:
Exception in thread "main" java.lang.IllegalArgumentException: The
schema:file://schema.xsd is not valid.
<element ref="element_from_namespace1"> is not resolvable.
at
org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:329)
at
org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:410)
at
org.exolab.castor.builder.SourceGenerator.generateSource(SourceGenerator.java:441)
at org.exolab.castor.builder.SourceGenerator.main(SourceGenerator.java:797)
However if I instead do this:
<xs:schema xmlns:n="http://namespace1">
and then still import like this:
<import namespace="http://namespace1" schemaLocation="http://www/schema.xsd"
and then this part becomes:
<xs:element ref="n:element_from_namespace1"/>
THEN castor works. Now maybe i'm wrong to use xmlns in elements like that, but
it seemed to validate fine with a number of different validators I used,
including xmlspy, oxygen, and ant with xerces.
So basically castor works fine when you define qualified namespaces and use them
in element tags, but not when you define the namespace in the element tag (which
should work equally well according to the schema standards). Hope this helps,
Cheers,
andrew.c
Thanks Andrew.