Hi Monika,

We're always happy to try to help the good folks of PG&E out...as long
as my electricity
stays on of course...(just teasing...I think)... :-)

My recommendation for you is to simply generate the source into two
separate packages...

such as:

java org.exolab.castor.builder.SourceGenerator -i schema1.xsd -package
com.pge.(whatever).fas

-and-

java org.exolab.castor.builder.SourceGenerator -i schema2.xsd -package
com.pge.(whatever).cis

Each package "cis" and "fas" will have it's own independant MessageBody
class.


If you really want to get fancy you can pull out the statusHeader
element into a shared schema to allow reuse, as such:

response-status.xsd

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
     targetNamespace="www.pge.com/response-status">
    <xs:element name="statusHeader">
        <xs:complexType>
            <xs:sequence>
              <xs:element name="statusCode" type="xs:string"/>
              <xs:element name="errorMessage" type="xs:string"/>
            </xs:sequence>
        </xs:complexType>  
    </xs:element>
</xs:schema>


generate this schema into a shared package as such:

java org.exolab.castor.builder.SourceGenerator -i schema2.xsd -package
com.pge.(whatever).core


Once you have your shared schema, you can then import this Schema into
your other two response schema as such:

<?xml version="1.0" encoding="utf-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";
    xmlns:res="www.pge.com/response-status">

  <xs:import schemaLocation="response-status.xsd"/>

  <xs:element name="Response1">
    <xs:complexType>
      <xs:sequence>
        <xs:element ref="res:statusHeader"/>
        <xs:element name="messageBody">
          <xs:complexType>
            <xs:sequence>
              <xs:element name="fasFlag" type="xs:string"/>
              <xs:element name="fasJobCode" type="xs:string"/>
              <xs:element name="fasArea" type="xs:string"/>
            </xs:sequence>
          </xs:complexType>  
        </xs:element>
      </xs:sequence>
    </xs:complexType>  
  </xs:element>
</xs:schema>

Then all you need to do is to set up the castorbuilder.properties file
to recognize the appropriate namespace to package mappings as such:

# XML namespace mapping to Java packages
#
org.exolab.castor.builder.nspackages=\
  www.pge.com/response-status=com.pge.(whatever).core


I hope you can follow my suggestion...and I hope it works well for you.

--Keith

"Koerdt, Monika" wrote:
> 
> I have the following two schemas and I want the generated classes to live in
> the same package.
> 
> schema 1:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
> 
>   <xs:element name="Response1">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="statusHeader">
>           <xs:complexType>
>             <xs:sequence>
>               <xs:element name="statusCode" type="xs:string"/>
>               <xs:element name="errorMessage" type="xs:string"/>
>             </xs:sequence>
>           </xs:complexType>
>         </xs:element>
>         <xs:element name="messageBody">
>           <xs:complexType>
>             <xs:sequence>
>               <xs:element name="fasFlag" type="xs:string"/>
>               <xs:element name="fasJobCode" type="xs:string"/>
>               <xs:element name="fasArea" type="xs:string"/>
>             </xs:sequence>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> schema 2:
> 
> <?xml version="1.0" encoding="utf-8"?>
> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema";>
> 
>   <xs:element name="Response2">
>     <xs:complexType>
>       <xs:sequence>
>         <xs:element name="statusHeader">
>           <xs:complexType>
>             <xs:sequence>
>               <xs:element name="statusCode" type="xs:string"/>
>               <xs:element name="errorMessage" type="xs:string"/>
>             </xs:sequence>
>           </xs:complexType>
>         </xs:element>
>         <xs:element name="messageBody">
>           <xs:complexType>
>             <xs:sequence>
>               <xs:element name="cisNumber" type="xs:string"/>
>               <xs:element name="cisData" type="xs:string"/>
>             </xs:sequence>
>           </xs:complexType>
>         </xs:element>
>       </xs:sequence>
>     </xs:complexType>
>   </xs:element>
> </xs:schema>
> 
> In the case of StatusHeader class, both responses share the same data, but
> the MessageBody class data in both responses is totally unrelated.  I could
> merge MessageBody into one big class, but I really don't want to do that.  I
> tried changing the names of the classes manually after generating the code,
> and that seems to work fine.  So I can have MessageBodyFAS and
> MessageBodyCIS classes that generates and XML with messageBody element.  Is
> there an easy way to specify the name of the class and the name of the
> element (complex type) so I don't have to change the name of the classes
> manually?
> 
> Thanks in advance,
> Monika Koerdt
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-dev

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

Reply via email to