Dear Arnaud,

Many thanks for your quick response.

In answer to your question, when my definition looks like this:

    <xs:complexType name="widgetresponsetype">
        <xs:sequence>
            <xs:element name="widgetname" type="xs:string" />
            <xs:element name="location">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="displayname" type="xs:string" />
                        <xs:element name="depotnumber" type="xs:string" />
                        <xs:element name="postalcode" type="xs:string" />
                    </xs:sequence>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
    </xs:complexType>

...you can see that the location element definition does create a class and
your suggestion worked when it was a child of the top level complex types
widgetresponsetype.  Many thanks for this.

It took me a long time to figure out the next bit, however...  If the
definition looks like this:

    <xs:complexType name="widgetresponsetype">
        <xs:sequence>
            <xs:element name="widgetname" type="xs:string" />
            <xs:element name="location" type="location" />
        </xs:sequence>
    </xs:complexType>

    <xs:complexType name="location">
        <xs:sequence>
            <xs:element name="displayname" type="xs:string" />
            <xs:element name="depotnumber" type="xs:string" />
            <xs:element name="postalcode" type="xs:string" />
        </xs:sequence>
    </xs:complexType>

Here I have the classic problem of two classes to be created with the same
name.  Ideally I want to rename the global complex type "location" to create
a java class TypeLocation or similar.  However, It took me ages to get this
to work.

The solution was that <complexTypeBinding> seems to require a path which
isn't prefixed with "/" whereas an <elementBinding> is (unless you're using
the complexType: prefix instead.  Previous emails to this forum have suggest
ed that one prefixes the path with a / and it confused me when moving across
to changing my complex types.

For example...

<elementBinding name="/response"> works
<elementBinding name="response"> also works
<complexTypeBinding name="location"> works
<complexTypeBinding name="/location"> does not work

Is this the intended behaviour?  Now I know what not to do, I can avoid
this.

Many thanks for your help in this.

Regards,

Phil Pinel

----- Original Message -----
From: "Arnaud Blandin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, February 12, 2003 10:19 PM
Subject: Re: [castor-dev] XML problem with binding and SourceGenerator


Hi Phil,

Let me ask you a couple of questions:

1- can you post the location element definition (is it creating a class)

2- you want to control the generation properties for an element so you
need to use <elementBinding> and not <complexTypeBinding> so your
approach is the good one.
However, the 'location' element is part of a top level complexType and
this is the tenet of the path creation: when creating a path for a
schema component, your starting point has to be a top-level schema
component.
I would advise you to replace

<element name="/response/widgetresponse/location"/>

by

<element name="complexType:widgetresponsetype /location"/>

I realize now that the 'name' name might not be the best name
ever...maybe path or schemapath should be better.

Let me know if it works for you,

Arnaud

> -----Original Message-----
> From: Phil Pinel [mailto:[EMAIL PROTECTED]]
> Sent: Wednesday, February 12, 2003 5:38 PM
> To: [EMAIL PROTECTED]
> Subject: [castor-dev] XML problem with binding and SourceGenerator
>
> I have a problem with a binding file using SourceGenerator in Castor
0.9.4.3.
>
> I have been given a top level XSD file which looks something like this
> (obviously, I've removed any confidential material, but the structure
is
> the same):
>
> <xs:include schemaLocation="Widgets.xsd"/>
> <xs:include schemaLocation="Thingys.xsd"/>
> <xs:element name="response">
> <xs:annotation>
> <xs:documentation>This element encapsulates a response
to a
> query</xs:documentation>
> </xs:annotation>
> <xs:complexType>
> <xs:sequence>
> <xs:element name="timestamp" type="xs:datetime"
/>
> <xs:choice>
> <xs:element name="widgetresponse"
> type="widgetresponsetype" />
> <xs:element name="thingyresponse"
> type="thingyresponsetype" />
> </xs:choice>
> </xs:sequence>
> </xs:complexType>
> </xs:element>
>
> As you can see, it references other XSD files for the different
response
> types.
>
> A widgetresponsetype is a complex type in Widgets.xsd which contains a
> child element of location.  Similarly, a thingyresponsetype defined in
> thingys.xsd has a child element of location.
>
> Both widgetresponsetype and thingyresponsetype are global complex
types
>
> I want to do the following in my binding file:
>
> <binding defaultBindingType="element">
> <elementBinding name="/response/widgetresponse/location">
> <java-class name="WidgetLocation"/>
> </elementBinding>
> <elementBinding name="/response/thingyresponse/location">
> <java-class name="ThingyLocation"/>
> </elementBinding>
> </binding>
>
> ...so that I don't end up with the same class name.
>
> However, this doesn't work!
>
> What am I doing wrong.  I can't get <complexTypeBinding> to work at
all.
> I'm beginning to wonder if the problem is that I've got an XSD spread
out
> over multiple files.  It isn't my XSD so I can't alter it in any way.
>
> Any help you can offer would be greatly appreciated.
>
> Thanks,
>
> Phil Pinel
>
> -----------------------------------------------------------
> 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

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

Reply via email to