ExoLab     OpenEJB     OpenJMS     OpenORB     Castor     Tyrex     
 

Main
  Home
  Download
  API
  Schema
  Mailing Lists
  CVS / Bugzilla
  Support

XML
  Using XML
  Source Generator
  Schema Support
  XML Mapping
  XML FAQ

JDO
  Using JDO
  JDO Config
  Types
  JDO Mapping
  JDO FAQ
  Other Features

Advanced JDO
  OQL
  Trans. & Locks
  Design
  KeyGen
  Long Trans.
  Nested Attrs.
  Pooling Examples
  Blobs and PostgreSQL

More
  Presentations
  The Examples
  Extras and 3rd Party Tools
  Test Framework -- JDO
  Test Framework -- XML
  Configuration
  Tips & Tricks
  Full JavaDoc

About
  License
  Contributors
  Status, Todo
  Changelog
  Library
  Contact

  



General
   How do I set the encoding?
   Why is my 'get' method called twice?
Introspection
   Can private methods be introspected?
Mapping
   My mapping file seems to have no effect!
   Are there any tools to automatically create a mapping file?
Source Code Generator
   Can I use a DTD with the source generator?
   My XML output looks incorrect, what could be wrong?
   How can I make the generated source code more JDO friendly?
Miscellaneous
   Is there a way to automatically create an XML Schema from an XML instance?

General

How do I set the encoding?

Create a new instance of the Marshaller class and use the setEncoding method. You'll also need to make sure the encoding for the Writer is set properly as well:

                  ...
                  String encoding = "ISO-8859-1";
                  FileOutputStream fos = new FileOutputStream("result.xml");
                  OutputStreamWriter osw = new OuputStreamWriter(fos, encoding);
                  Marshaller marshaller = new Marshaller(osw);
                  marshaller.setEncoding(encoding);
                  ...
               

Why is my 'get' method called twice?

The get method will be called a second time during the validation process. To prevent this from happening simply disable validation on the Marshaller or Unmarshaller.

Introspection

Can private methods be introspected?

Castor does not currently support introspection of private methods. Please make sure proper public accesssor methods are available for all fields that you wish to be handled by the Marshalling Framework.

Mapping

My mapping file seems to have no effect!

Make sure you are not using one of the static methods on the Marshaller/Unmarshaller. Any configuration changes that you make to the Marshaller or Unmarshaller are not available from the static methods.

Are there any tools to automatically create a mapping file?

Yes! We provide one such tool, see org.exolab.castor.tools.MappingTool. There are some 3rd party tools as well.

Source Code Generator

Can I use a DTD with the source generator?

Not directly, however you can convert your DTD to an XML Schema fairly easily. We provide a tool (org.exolab.castor.xml.dtd.Converter) to do this. You can also use any number of 3rd-party tools such as XML Spy or XML Authority.

My XML output looks incorrect, what could be wrong?

Are the generated class descriptors compiled? Make sure they get compiled along with the source code for the object model.

How can I make the generated source code more JDO friendly?

For Castor 0.9.4 and above:

Castor JDO requires a reference to the actual collection to be returned from the get-method. By default the source generator does not provide such a method. To enable such methods to be created, simple add the following line to your castorbuilder.properties file:

                   org.exolab.castor.builder.extraCollectionMethods=true
                
Note: The default castorbuilder.properties file has this line commented out, simply uncomment it.

Your mapping file will also need to be updated to include the proper set/get method names.

Miscellaneous

Is there a way to automatically create an XML Schema from an XML instance?

Yes! We provide such a tool. Please see org.exolab.castor.xml.schema.util.XMLInstance2Schema. It's not 100% perfect, but it does a reasonable job.

 
   
  
   
 


Copyright ) 1999-2003 ExoLab Group. All rights reserved.
 
Java, EJB, JDBC, JNDI, JTA, Sun, Sun Microsystems are trademarks or registered trademarks of Sun Microsystems, Inc. in the United States and in other countries. XML, XML Schema, XSLT and related standards are trademarks or registered trademarks of MIT, INRIA, Keio or others, and a product of the World Wide Web Consortium. All other product names mentioned herein are trademarks of their respective owners.