Hi, first let me thank all the Castor developers for providing the Java community with this great tool. Recently I discouvered that Castor seems to have problems with base64 encoded simple contents in elements.
In more detail: Mashalling an element with the following type
<complexType>
<simpleContent>
<extension base="base64Binary"/>
</simpleContent>
</complexType>
outputs an element with a content looking simmilar to
[B@1503a3
which seems to be the result of the toString() method called on an
Java byte array.
Attached you can find a test-case to demonstrate the problem stated
above and a patch to the Marshaller/Unmarshaller that seems to solve
the problem. But a simmilar problem seems to occur with hexBinary
contents, so I think a more general solution would be superior.
Three files are attached to this mail:
base64content-testcase.tgz The .java and .xsd files for the
test-case
base64content-build.patch A patch to build.xml for building
and running the test-case
base64content.patch A patch to the marshalling
framework that solves the problem
All three files should be extracted / applied in the main Castor
directory (the one *containing* the src/ directory) with the following
commands:
tar -xvzf base64content-testcase.tgz
patch -p0 < base64content-build.patch
patch -p0 < base64content.patch
The test-case can now be built with and run with
ant -f src/build.xml run-tests
Running the test-case on the current CVS version of Castor reports the
following exception:
Exception in thread "main" org.xml.sax.SAXException: unable to add text
content to signature due to the following error:
java.lang.IllegalStateException: java.lang.ClassCastException:
java.lang.String
at
org.exolab.castor.xml.UnmarshalHandler.endElement(UnmarshalHandler.java:448)
at
org.apache.xerces.parsers.SAXParser.endElement(SAXParser.java:1392)
at
org.apache.xerces.validators.common.XMLValidator.callEndElement(XMLValidator.java:1436)
at
org.apache.xerces.framework.XMLDocumentScanner$ContentDispatcher.dispatch(XMLDocumentScanner.java:1205)
at
org.apache.xerces.framework.XMLDocumentScanner.parseSome(XMLDocumentScanner.java:381)
at org.apache.xerces.framework.XMLParser.parse(XMLParser.java:1035)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:338)
at
org.exolab.castor.xml.Unmarshaller.unmarshal(Unmarshaller.java:270)
at
haui.castor.test.TestBase64Content.testUnmarshal(TestBase64Content.java:14)
at
haui.castor.test.TestBase64Content.main(TestBase64Content.java:43)
Best regards, Bernhard Haumacher.
------------------------------------------------------------------------
Dipl. Inform. Bernhard Haumacher, University of Karlsruhe
Programming Systems Lab, D-76131 Karlsruhe, Germany
phone:+49-721-608-3495 fax:+49-180-505254695527
mailto:[EMAIL PROTECTED] http://wwwipd.ira.uka.de/~hauma/
base64content-testcase.tgz
Description: Binary data
base64content-build.patch
Description: Binary data
base64content.patch
Description: Binary data
