Ok, making some headway. But as I play more questions arise.

First off, this is a follow-up to the email I sent a bit ago. I am working 
on the invoice.xsd which is included in the src directory for Castor. I 
executed the Source Generator like so:






java -cp %CP% org.exolab.castor.builder.SourceGeneratorMain -i invoice.xsd 
-package test




I was able to created objects and set objects to the invoice. This is 
where my next question comes from:

There is a class called
  ShippingDate shipDate = new ShippingDate();
        shipDate.setDate(new Date());
        shipDate.setTime(new Time());
 
Which gets created from the XSD. The Date and Time are of 
org.exolab.castor.types.Date.Date() and also 
org.exolab.castor.Time.Time(). So am I suposed to create Objects of that 
type? as opposed to normal Java Date objects? It would appear that this 
would couple me tightly to the Castor product? Can I use simple Date 
objects as opposed to this? And if so, how would this be accomplished? Do 
I need to alter the xsd?

Any help would be greatly appreciated.

Sincerely
Scott








Werner Guttmann <[EMAIL PROTECTED]> 
07/04/2008 02:15 AM
Please respond to
[email protected]


To
[email protected]
cc

Subject
Re: [castor-user] How to Populate Binding Objects






Scott,

Scott Purcell wrote:
> Hello,
> 
> I have created a XSD document with many complex types, and have used the 

> XML Code generator (SourceGeneratorMain) to create java binding files. 
> This is all good and works well.
Hmm ... let me try to understand one thing here. When you have used the
XML code generator, you have turned off creastion of descriptor classes
and turned on creation of a mapping file, correct ? If that's the case,
why ? It should be the other way around. See below .....

Please note, that a binding file is something completely different.
The term 'binding file' is used in the context of code generation to
overcome naming collisions.

> 
> Now, I need to somehow (this is where my question lies) "instantiate" 
the 
> binding files, populate them, and then marshal the objects to XML. I am 
> not sure how this is accomplished? Could someone give me some insight as 

> to how this works?
> 
> My workflow will be like so:
> Once the binding files are created (which they are) I have the need to 
> instantiate the objects, populate them with different data and then 
> marshall the data to xml.

Assuming that you have generated source code (including descriptor
classes, that is) from your XML schema, here's what you have to do to
marshal an object instance to XML.

<code>
XMLContext context = new XMLContext();

Marsdaller marshaller = context.createMarshaller();

YourObject yourObject = .... ;

marshaller.marshal(yourObject);
</code>

If (and only if) you have the descriptor classes on your classpath,
Castor will just marshal XML according to your definitions in your XMl
schema.

Does this make sense ?

Werner
> 
> Thanks,
> Scott
> 
> 
> 
> 
> 
> CONFIDENTIALITY NOTICE
> This e-mail message and any attachments are only for the use of the 
intended recipient and may contain information that is privileged, 
confidential or exempt from disclosure under applicable law. If you are 
not the intended recipient, any disclosure, distribution or other use of 
this e-mail message or attachments is prohibited. If you have received 
this e-mail message in error, please delete and notify the sender 
immediately. Thank you.

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email







CONFIDENTIALITY NOTICE
This e-mail message and any attachments are only for the use of the intended 
recipient and may contain information that is privileged, confidential or 
exempt from disclosure under applicable law. If you are not the intended 
recipient, any disclosure, distribution or other use of this e-mail message or 
attachments is prohibited. If you have received this e-mail message in error, 
please delete and notify the sender immediately. Thank you.

Reply via email to