Hi I have following which is not generating class file for complextypes using bindigs.xml file.
Sample.xsd file
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" attributeFormDefault="unqualified">
<xs:element name="Data">
<xs:annotation>
<xs:documentation>This section contains the supply chain message
data</xs:documentation>
</xs:annotation>
<xs:complexType>
<xs:choice>
<xs:element name="PurchaseOrder">
<xs:complexType>
<xs:sequence>
<xs:element name="LineItem" type="LineItemType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="OrderNumber" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="OrderReceipt">
<xs:complexType>
<xs:sequence>
<xs:element name="LineItem" type="ReceiptLineItemType" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="OrderNumber" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:choice>
</xs:complexType>
</xs:element>
<xs:complexType name="SkuType">
<xs:annotation>
<xs:documentation>Contains Product Identifier</xs:documentation>
</xs:annotation>
<xs:sequence>
<xs:element name="Number" type="xs:integer"/>
<xs:element name="ID" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ReceiptSkuType">
<xs:annotation>
<xs:documentation>Contains Product Identifier</xs:documentation>
</xs:annotation>
<xs:complexContent>
<xs:extension base="SkuType">
<xs:sequence>
<xs:element name="InternalID" type="xs:string"/>
</xs:sequence>
</xs:extension>
</xs:complexContent>
</xs:complexType>
<xs:complexType name="LineItemType">
<xs:sequence>
<xs:element name="Sku" type="SkuType"/>
<xs:element name="Value" type="xs:double"/>
<xs:element name="BillingInstructions" type="xs:string"/>
<xs:element name="DeliveryDate" type="xs:date"/>
<xs:element name="Number" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="ReceiptLineItemType">
<xs:sequence>
<xs:element name="Sku" type="ReceiptSkuType"/>
<xs:element name="Value" type="xs:double"/>
<xs:element name="PackingDescription" type="xs:string"/>
<xs:element name="ShipDate" type="xs:dateTime"/>
<xs:element name="Number" type="xs:integer"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
bindings.xml
<binding xmlns="http://www.castor.org/SourceGenerator/Binding"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.castor.org/SourceGenerator/Binding
C:\\Castor\\xsd\\binding.xsd"
defaultBinding="element">
<elementBinding name="/Data/PurchaseOrder/LineItem">
<java-class name="PurchaseOrderLineItem"/>
</elementBinding>
<elementBinding name="/Data/OrderReceipt/LineItem">
<java-class name="OrderReceiptLineItem1"/>
</elementBinding>
<elementBinding name="/complexType:ReceiptLineItemType/Sku">
<java-class name="Xxxxxx"/>
</elementBinding>
<elementBinding name="/complexType:LineItemType/Sku">
<java-class name="Yyyyyy"/>
</elementBinding>
</binding>
pom.xml plugin configuration :
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>castor-maven-plugin</artifactId>
<version>1.0</version>
<executions>
<execution>
<goals>
<goal>generate</goal>
</goals>
</execution>
</executions>
<configuration>
<bindingfile>src/main/castor/binding.xml</bindingfile>
<schema>src/main/castor/sample.xsd</schema>
<packaging>com.sg.defi.castor.correspondence</packaging>
<properties>src/main/castor/castorbuilder.properties</properties>
</configuration>
</plugin>
Is there anything to be changed in any .properties file , inorder to get class files generated with the name given bindings.xml file for complextypes.
Figured it out ! ,
Modify the binding.xml for complextypes to
<elementBinding name="/complexType:ReceiptLineItemType/Sku">
<java-class name="Xxxxxx"/>
</elementBinding>
Change the above code to
<complexTypeBinding name="complexType:ReceiptLineItemType/Sku">
<java-class name="Xxxxxx"/>
</complexTypeBinding>
Very sadly the castor website itself posted the example in a wrong way
http://www.castor.org/how-to-use-a-binding-file-with-source-generation.html