Alex,

You're not alone with the "binding file" blues, trust me, it's poorly
documented (due to lack of time I suppose) and also gives me a headache
when I try and figure out how to use it.

Since you don't have a complexType called "status", you probably don't
want to be using a complexTypeBinding element:

<complexTypeBinding name="createUser/status">

Instead you want to use an elementBinding:

<elementBinding name="complexType:createUser/status">

You can also nest component bindings as such to make it more readable:

<complexTypeBinding name="createUser">
   <elementBinding name="status">
    ...
   </elementBinding>
</complexTypeBinding>

I hope that helps,

--Keith

Alex Burmester wrote:
> 
> So I'm comfortable using castor source generator and then using the
> generated classes to construct xml messages but I still feel like a moron
> when trying to do anything with the binding file.  I am trying to use the
> binding file to do things like avoid naming conflicts but it doesn't seem
> to do anything.  I have looked over the example binding file provided in
> the castor examples but while it seems to work it's not helping me get to
> the bottom of this:
> 
> My test case I'm using currently is as follows:
> mytest.xsd contains
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="http://www.example.com";
> xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
> attributeFormDefault="unqualified">
>         <xs:include schemaLocation="mytypes.xsd"/>
>         <xs:element name="user" type="createUser"/>
>         <xs:complexType name="createUser">
>                 <xs:sequence>
>                         <xs:element name="status" type="createStatus"
> minOccurs="0"/>
>                 </xs:sequence>
>         </xs:complexType>
> </xs:schema>
> 
> mytypes.xsd contains
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="http://www.example.com";
> xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
> attributeFormDefault="unqualified">
>         <xs:complexType name="createStatus">
>                 <xs:sequence>
>                         <xs:element name="id" type="xs:long"/>
>                 </xs:sequence>
>         </xs:complexType>
>         <xs:complexType name="updateStatus">
>                 <xs:sequence>
>                         <xs:element name="id" type="xs:string"/>
>                 </xs:sequence>
>         </xs:complexType>
> </xs:schema>
> 
> mytest2.xsd contains
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="http://www.example.com";
> xmlns:xs="http://www.w3.org/2001/XMLSchema"; elementFormDefault="qualified"
> attributeFormDefault="unqualified">
>         <xs:include schemaLocation="mytypes.xsd"/>
>         <xs:element name="user2" type="updateUser"/>
>         <xs:complexType name="updateUser">
>                 <xs:sequence>
>                         <xs:element name="status" type="updateStatus"
> minOccurs="0"/>
>                 </xs:sequence>
>         </xs:complexType>
> </xs:schema>
> 
> bindingMytest.xml contains:
> <?xml version="1.0"?>
> <cbf:binding xmlns:cbf="http://www.castor.org/SourceGenerator/Binding";
>              defaultBindingType='element'>
> 
>      <cbf:package>
>           <cbf:name>test</cbf:name>
>           <cbf:namespace>http://www.example.com</cbf:namespace>
>      </cbf:package>
> 
>     <cbf:complexTypeBinding name="createUser/status">
>         <cbf:java-class name="createStatus"/>
>     </cbf:complexTypeBinding>
> 
>     <cbf:complexTypeBinding name="updateUser/status">
>         <cbf:java-class name="updateStatus"/>
>     </cbf:complexTypeBinding>
> 
>  </cbf:binding>
> 
> my generation commands look like:
> java -classpath
> ./../java/castor-0.9.5.3/castor-0.9.5.3-xml.jar:../../java/xerces-2_6_2/xercesImpl.jar
> org.exolab.castor.builder.SourceGenerator -verbose -i mytest.xsd
> -binding-file bindingMytest.xml -package mytest
> 
> java -classpath
> ./../java/castor-0.9.5.3/castor-0.9.5.3-xml.jar:../../java/xerces-2_6_2/xercesImpl.jar
> org.exolab.castor.builder.SourceGenerator -verbose -i mytest2.xsd
> -binding-file bindingMytest.xml -package mytest
> 
> I still get the Status.java class generated which only extends
> CreateStatus and UpdateUser still uses the Status class
> 
> Any suggestions?
> 
> Thanks,
> 
> Alex.
> 
> -----------------------------------------------------------
> If you wish to unsubscribe from this mailing, send mail to
> [EMAIL PROTECTED] with a subject of:
>         unsubscribe castor-user



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

Reply via email to