Hi Thomas, Thomas Cherel wrote: > I am trying to programmatically set some of the castor properties to > customize the XML marshalling behavior and it does not seem to work. Well, to keep a long story short, there was a bug with InternalContext that prevented setting some of those properties programmaticly and prevented propagation from XMLContext to Un-/Marshaller. To my knowledge, that has been fixed with Castor 1.3.
> Code snippet and output are included below. > > I am using Casto 1.2 and based on this document, > http://www.castor.org/1.3/xml-properties.html#Current-configuration-file, > my understanding is that it should work: > > As of Castor 1.1, it is possible to read and set the value of > properties programmatically using the getProperty(String) and > setProperty(String,String) on the following classes: > > - org.exolab.castor.xml.Unmarshaller - > org.exolab.castor.xml.Marshaller - org.exolab.castor.xml.XMLContext > > Whilst using the setter methods on the first two classes will change > the settings of the respective instances only, using the > setProperty() method on the XMLContext class will change the > configuration globally, and affect all Unmarshaller and Marshaller > instances created thereafter using the createUnmarshaller() and > createMarshaller() methods. > > I also tried to set the property at the XMLContext level, no success. > The only I am able to make it work is with a castor.properties file > in the classpath. Yes, correct. See above. > Am I missing something obvious? > > I did not try Castor 1.3 as I have a hard requirement for JRE 1.4 > support. Oh lord .... how come not a single user did raise any concerns when we *publicly* asked about three months ago about our desire to upgrade to Java 5.0. Having said that, there might be ways to *maybe* release Castor 1.2.1 on specific request. But to be honest, given our questions months ago, this will be very hard to argue (non-commercially). > Op1Request op = new Op1Request(); op.setArg1(12345); > > Marshaller marshaller = new Marshaller(new > OutputStreamWriter(System.out)); > marshaller.setProperty("org.exolab.castor.xml.introspector.primitive.nodetype", > "element"); marshaller.setProperty("org.exolab.castor.xml.naming", > "mixed"); marshaller.setProperty("org.exolab.castor.indent", "true"); > marshaller.marshal(op); > > And I get the following output showing that the properties are not > taken into account: > > <?xml version="1.0" encoding="UTF-8"?> <op1-request arg1="12345"/> > > > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > --------------------------------------------------------------------- To unsubscribe from this list, please visit: http://xircles.codehaus.org/manage_email

