Hi,
I am trying to use the SourceGenerator from *within* another program and am
having problems with the XML namespaces to Java packages mappings. Here are
my 2 XSD files. I am trying to generate itema.java which contains "itemb"'s,
and so that itema.java lives in a diff package then itemb.java and
itema.java does an java import of the appropriate package to get itemb.

Below are the two XSD files, following is the Java code to exec the
SourceGenerator. The problem here is that SourceGenerator does properly
generate ItemA.java, however ItemA.java does NOT do a java "import" of
"packageb". (i.e. import packageb.*) Which it needs in order to reference
the "itemb" class.

What am I doing wrong with regards to my XSD schemas whereby SourceGenerator
is not properly specifying the import of "packageb" according to my
namespace import -> package mapping as specified in the java below.


-------------------------
itema.xsd
-----------------------------

<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  targetNamespace=http://www.mydomain.com/a";
  xmlns:org-b=http://www.mydomain.com/b";
  >

  <xsd:import
     namespace="http://www.mydomain.com/b";
     schemaLocation="../b/itemb.xsd"/>

<xsd:element name="itema">
  <xsd:complexType>
   <xsd:sequence>
         <xsd:element name="propa" type="xsd:string" />
         <xsd:element ref="ListOfItemBs" minOccurs="0" maxOccurs="1"/>
      </xsd:sequence>
  </xsd:complexType>
 </xsd:element>

  <xsd:element name="ListOfItemBs">
  <xsd:complexType>
   <xsd:sequence>
   <xsd:element ref="org-b:itemb" minOccurs="0" maxOccurs="unbounded"/>
   </xsd:sequence>
  </xsd:complexType>
 </xsd:element>
 </xsd:schema>


-------------------------
itemb.xsd
-----------------------------

<xsd:schema
  xmlns:xsd="http://www.w3.org/2001/XMLSchema";
  targetNamespace=http://www.mydomain.com/b";
  >
<xsd:element name="itemb">
  <xsd:complexType>
   <xsd:sequence>
      <xsd:element name="propb" type="xsd:string" />
      </xsd:sequence>
  </xsd:complexType>
 </xsd:element>

 </xsd:schema>


------------------
exec of SourceGenerator
----------------------------

// erate castor source files
org.exolab.castor.builder.SourceGenerator sg = new
org.exolab.castor.builder.SourceGenerator();
Properties props = new Properties();
props.setProperty("org.exolab.castor.builder.nspackages","http://www.mydomai
n.com/b=packageb");
sg.setDefaultProperties(props);
sg.setPrimitiveWrapper(true);
sg.setEqualsMethod(true);
sg.setSuppressNonFatalWarnings(true);
sg.setDestDir("c:\\temp\\java\\src\\");
sg.generateSource("itema.xsd","packagea" );



----------------------------------------------------------- 
If you wish to unsubscribe from this mailing, send mail to
[EMAIL PROTECTED] with a subject of:
        unsubscribe castor-user

Reply via email to