sgu wrote:
> 
> Hi, Keith, etc:
> 
> I don't know why I cannot get any response after I
> repeatedly post the same question on this forum.I have
> searched through archives and docs, and found nothing
> related to this.

I can shed some light on this...

We all held a meeting the other day, and we choose by random the people
that we refuse to answer questions from. Unfortunately your name was
choosen...but since it appears that you're on to us, I guess I can make
an exception and try to answer you mail. I just hope the others don't
see me doing this or I could be excluded from choosing the next round
names for people to annoy! :-)

> 
> I am evaluating xmlbeans and castor, Castor can do
> what xmlbeans cannot do, for example: generate default
> constructors for java objects, implement equals,
> cleaner   getters/setters, etc. We need these nice
> things in order to integrate with Hibernate. The only
> thing I need to know now is: how to generate component
> objects for nested elements while manipulating their
> names. If Castor can do this, we may go ahead
> integrate Castor with Huibernate. I am wondering if
> castor-xml can do this.
> 
> so, please give me a word on this so that I can choose
> which path to go. Thanks.
> 

Castor has a source generation binding file which will let you custom
the names of the fields...

> I have 2 schema files info.xsd and message.xsd, if I
> use include as following:
> 
> info.xsd:
> 
> ......
> <xs:element name="info">
> <xs:complexType>
>     <xs:all>
>         <xs:element name="createdBy" type="xs:string"/>
>     </xs:all>
> </xs:complexType>
> </xs:element>
> ......
> 
> message.xsd:
> <xs:include schemaLocation="info.xsd"
> namespace="http://www.w3.org/2001/XMLSchema"/>
> 
> <xs:element name="message">
> <xs:complexType>
>   <xs:all>
>   <xs:element name="id" type="xs:string"/>
>   <xs:element ref="info" minOccurs="1" maxOccurs="1"
> />
>   </xs:all>
> </xs:complexType>
> </xs:element>
> 
> I get the correct results:
> Info getInfo();


OK...so far so good....


> 
> But if I want to have something like this:
> Info getInfomation();
> 
> Here information should be of type Info in Message
> class, I modified message.xsd:
> 
> <xs:element name="message">
> <xs:complexType>
>   <xs:all>
>   <xs:element name="id" type="xs:string"/>
>   <xs:element name="infomation"
>      type="info" minOccurs="1" maxOccurs="1" />
>   </xs:all>
> </xs:complexType>
> </xs:element>
> 
> then I still get:
> 
> Object getInformation();
>


Right...because type "info" doesn't exist. At least not in the schema
fragment you gave. Actually, I'm surprised no error message is given
about that.

You can refer to an element using element ref, but you cannot ref to an
anonymous complexType definition.

If you have a complexType such as:

<complexType name="info">
    <xs:all>
       <xs:element name="createdBy" type="xs:string"/>
    </xs:all>
 ...
</complexType> 

Then it would work...because type="info" would then refer to this type.

> It seems that using ref can generate correct
> getter/setter for containing objects, but it does let
> me to specify property names. Is there any way around?

When using element ref, no you can't change the name of the element,
it's purely a reference to an existing declaration.

Castor will let you change the name of the getter/setter methods however
in the binding file.

For an example binding file take a look at the
src/examples/SourceGenerator directory, it contains a bindingInvoice.xml
file which should be a good enough example to get you started with that.

And please...don't tell anyone I responded to your e-mail...it could
ruin my reputation! ;-)

I hope that helps,

--Keith

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

Reply via email to