I have two xsd files:
base.xsd:
<schema
targetNamespace="http://www.myorg.com/base"
elementFormDefault="qualified"
attributeFormDefault="unqualified"
xmlns="http://www.w3.org/2001/XMLSchema">
...
<complexType name="NrmClass">
...
</complexType>
...
</schema>
main.xsd is a schema where we want to use a type from base.xsd
<schema
targetNamespace="http://www.myorg.com/main"
elementFormDefault="qualified"
xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:xn="http://www.myorg.com/base">
<import namespace="http://www.myorg.com/base"/>
...
<element>
<complexType>
<complexContent>
<extension base="xn:NrmClass">
...
</extension>
</complexContent>
</complexType>
</element>
...
</schema>
When I try to compile both, I receive the following error:
> xjc base.xsd main.xsd
parsing a schema...
[ERROR] src-resolve: Cannot resolve the name 'xn:NrmClass' to a(n) 'type definition' component.
line 48 of file:/main.xsd
What is wrong here?
You want to try specifying the file for the XSD you're importing, as in:
<xsd:import namespace="http://www.myorg.com/base" schemaLocation="base.xsd"/>
This works well if you keep them side by side anyway. That way you can compile them in one operation.
If you want to run xjc separately (like they are built as separate modules), then you can use an episode file.
Have a look at "episodes": http://weblogs.java.net/blog/kohsuke/archive/2006/09/separate_compil.html
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With