Werner Guttmann wrote: > > How do these objects relate to each other ? Are they part of e.g. an > inheritance hierarchy ? Will each of those objects be mapped ? > Originally, they weren't part of a hierarchy. What I ended up trying was the example on the castor homepage where a hashtable of objects was wrapped inside a class and that that class would be written. I couldn't get this to work though.
Werner Guttmann wrote: > > Hi, > > can you define the term 'multiple objects' for us ? > > Werner > I mean a sequence of objects. They have a list of authors within the book object they marshal, so I suppose technically they cover it. In this case, I'd want to do multiple books. In the end what has worked for me is: http://www.castor.org/how-to-map-a-list-at-root.html The setRootElement method is very useful. This is what I am doing now: try { //Create list from hashtable List myObjectList = new LinkedList(); Enumeration keySetNumeration = myObjectTable.keys(); while(keySetNumeration.hasMoreElements()) { myObjectList.add(myObjectTable.get(keySetNumeration.nextElement())); } //Preparing writer BufferedWriter theBufferedFileWriter = new BufferedWriter(new FileWriter("output.xml")); StringWriter theStringWriter = new StringWriter(); //Preparing marshaller Marshaller m = new Marshaller(); Mapping mapping = new Mapping(); mapping.loadMapping("mapping.xml"); m.setMapping(mapping); m.setWriter(theStringWriter); m.setRootElement("rootObject"); m.marshal(myObjectList); //Writing XML file theBufferedFileWriter.write(theStringWriter.toString()); theBufferedFileWriter.close(); theStringWriter.close(); } catch (Exception e) { System.err.println(e.getMessage()); e.printStackTrace(System.err); } So my problem is solved for now :) -- View this message in context: http://www.nabble.com/Marshalling-to-XML-conforming-to-existing-XSD-tp18611513p18711448.html Sent from the Castor - User mailing list archive at Nabble.com. --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

