Martin,
 
there's a JDO HOW-TO section on http://castor.codehaus.org. Now, if I added a similar section for Castor XML, would you be willing to supply me with a short patch to allow me to integrate your findings with this new section. This information is simply to valuable to 'loose' it in a maiing list archive ....
 
Werner


From: Martin Graney [mailto:[EMAIL PROTECTED]
Sent: Montag, 31. Oktober 2005 16:31
To: [email protected]
Subject: [castor-user] RE: Binding File to resolve element collision - Solution

Hi All

 

As I didn’t get a response from the user support group to my earlier question I downloaded the source and stepped through it to see what the binding file should actually contain to get it to work.

 

I was on the right path, which made me feel good, but there are no ‘real world’ examples on the Castor binding file out there for me to use as reference.

 

For the information of anyone who might Google the group to find out more on the Castor binding file.;

 

I have an XSD provided by a third party and I can not change the format of this XSD in any way.

It has an element located at Loonaangifte/AdminstratieveEenheid/TijdvakAangifte/VolledigeAangifte/CollectieveAangifte.

However there is also an element at another location with the same name.

These two elements are attached to different types, so a binding file MUST be used to separate out the generated java files.

 

The binding file works using the notation as described in the on-line documentation [presently here: http://castor.codehaus.org/sourcegen.html#Binding-File]

However, the paths used for the element names are relative to their placement in the XSD, *not* to the eventual location in the generated XML that the XSD defines. [Something not too clear in the documentation]

 

The element CollectieveAangifte that I want to override is actually located at TijdvakAangifteType/VolledigeAangifte/CollectieveAangifte relative to the root of the XSD.

The element TijdvakAangifteType is actually a complexType located on the root of the XSD.

 

Using the BNF definition described in the online documentation I created a binding for the Loonaangifte/AdminstratieveEenheid/TijdvakAangifte/VolledigeAangifte/CollectieveAangifte element to the VolledigeAangifteCollectieveAangifte.java file using the following Castor binding file definition.

 

<?xml version="1.0" encoding="UTF-8"?>

<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:\DOCUME~1\mga\Desktop\binding.xsd"

 

    defaultBindingType="element">

 

      <elementBinding name="complexType:TijdvakAangifteType/VolledigeAangifte/CollectieveAangifte">

      <java-class name="VolledigeAangifteCollectieveAangifte" />

      </elementBinding>

</binding>

 

I hope this short ‘real world’ example is helpful for anyone else that is in my previous situation.

 

Thanks all the same,

 

Groetjes

 

Martin Graney

LeanApps BV

 

 


From: Martin Graney [mailto:[EMAIL PROTECTED]
Sent: Friday, October 28, 2005 12:52
To: '[email protected]'
Subject: Binding File to resolve element collision

 

Hi

 

I have a problem where a schema I have has two complex elements in different locations with identical names, but tied to different complex types.

As such I encounter a collision when using the source generator.

 

I tried using the following binding file but found that it did not work. [It does not stack-trace, but also does not seem to do anything..]

 

<?xml version="1.0" encoding="UTF-8"?>

<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:\DOCUME~1\mga\Desktop\binding.xsd"

 

    defaultBindingType="element">

 

    <complexTypeBinding name="complexType:Loonaangifte/complexType:AdminstratieveEenheid/complexType:TijdvakAangifte/complexType:VolledigeAangifte/complexType:CollectieveAangifte">

        <java-class name="TijdvakAangifteCollectieveAangifte">

        </java-class>

    </complexTypeBinding>

</binding>

 

The binding-file section of the documentation is pretty sparse and I am having difficulty trying to extrapolate the correct implementation from the BNF notation.

 

What I am attempting to do is bind the CollectieveAangifte complex element into a differently named generated class TijdvakAangifteCollectieveAangifte, to resolve the generation collision. [And, hopefully, this will (un)marshal correctly at the end of this]

 

Does anyone have a clue how this can be achieved?

 

Thanks to you all in advance

 

Martin Graney

 

Software Developer

LeanApps BV

Reply via email to