Hello Werner.
Unfortunately, I'm not pursuing castor 1.3 at the moment, so trying that
change is a bit difficult.
Ironically, my original code (marshaller.setProperty
("org.exolab.castor.indent", "true");) does work in castor 1.1.2.1, which
the project I'm working on uses. However the indenting adds so much
whitespace, that I've written a routine to regex on the XML string and
just insert NLs before selected elements. (We generate big files.) So
I'm not now using that setProperty!
I think I successfully migrated all the bits I needed to, to castor 1.3.
But I found resolving didn't work, in the existing code which works fine
using 1.1.2.1. My conclusion is that there is some functional difference
between 1.1.2.1 and 1.3. Or it could be an error I made in the change.
Either way, I've posponed the upgrade to 1.3 for the moment, in the
interests of getting real (non-castor) bugs sorted out. Somehow that is
the pressure that always prevails over code 'maintenance'. Personally I
feel worried when code is in a state where it can't use the latest release
of libraries.
Regards,
Ken.
Werner Guttmann <[email protected]>
23/04/2009 04:21 PM
Please respond to
[email protected]
To
[email protected]
cc
Subject
Re: [castor-user] castor 1.3 properties not working?
Hi Ken,
[email protected] wrote:
> My first post to this list, so I hope this email is OK.
> (Werner made me do it.)
Yes, I did, and I hope I didn't not ask for something completely
unnatural .. ;-).
> With respect to:
> http://www.mail-archive.com/[email protected]/msg07192.html
>
> The following code snippet:
>
> ...
> osw = new OutputStreamWriter(output.getOutputStream(),
> TagDBInstance.ENCODING);
> ...
> Marshaller marshaller = new Marshaller(osw);
> marshaller.setEncoding(TagDBInstance.ENCODING);
> marshaller.setSuppressNamespaces(true);
> marshaller.setValidation(CGateProperties.get("tag-validate-db",
> "yes").equalsIgnoreCase("yes"));
> marshaller.setProperty("org.exolab.castor.indent", "true");
> marshaller.marshal(installation); // write out to the file
> <path>.new
> osw.close();
>
> results in a file containing:
>
> <?xml version="1.0" encoding="utf-8"?>
>
<Installation><OID>1a4bcf00-0fb2-102c-961c-f8fc7867ab87</OID><DBVersion>2.2</DBVersion>........
>
> ie the marshaller.setProperty("org.exolab.castor.indent", "true"); line
> is not working.
>
> This is in castor 1.3.
>
> Either there is something wrong in the code, or it is a bug.
It probably is a bug, but let's see whether there is an easy workaround.
Can you please change your code above as follows:
XMLContext context = new XMLContext(),
Marshaller marshaller = context.createMarshaller();
marshaller.setWriter(osw),
marshaller.setProperty("org.exolab.castor.indent", "true");
marshaller.setEncoding(TagDBInstance.ENCODING);
marshaller.setSuppressNamespaces(true);
marshaller.setValidation(CGateProperties.get("tag-validate-db", "yes")
.equalsIgnoreCase("yes"));
marshaller.marshal(installation); // write out to the file
If that does not help either, try to invoke the setProperty() call on
the XMLContext instance.
I hope this helps
Regards
Werner
> If it is the code, I'd appreciate being set straight.
>
> Unfortunately the documentation seems to be lagging behind the releases,
Yes, it does. Mind indicating where things should be changed in your view
?
> so I'm using net searches for answers to my castor problems.
>
> Ken Wagnitz.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email