I'm marshalling a wrapper class that embeds a superclass that could, in
actual fact, be one of several subclasses.
After seeing the annoying attributes in the resulting xml for the sub class
AxClass:
xsi:type="java:pollux.AxClass" xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
and looking into the marshal private method, I added a minor fix to the
Castor Marshaller class .
Also, I needed a "getReadMethod()" for the FieldhandlerImpl class, that
just returns, unsurprisingly, the get method.
The cvs diffs are as follows:
cvs -z9 diff Marshaller.java (in directory D:
\castor9_3_19\castor_current\castor\src\main\org\exolab\castor\xml\)
Index: Marshaller.java
===================================================================
RCS file:
/cvs/castor/castor/src/main/org/exolab/castor/xml/Marshaller.java,v
retrieving revision 1.108
diff -r1.108 Marshaller.java
851a852
> boolean override = false;
855a857,864
> //--- pmv -----------------------------
> //--- if descriptor is of a class extended by class
found by
> //--- classDescriptorResolver, then we should be able
to
> //--- marshall without the xsi:type insertion.
> if(classDesc != null && descriptor.getFieldType
().isAssignableFrom(_class)) {
> saveType = false;
> override = true;
> }
871c880,883
< else if (descriptor.getXMLName()==null)
---
> //--- pmv
> //--- add additional test --------------------
> else if (descriptor.getXMLName()==null || override)
> //else if (descriptor.getXMLName()==null)
*****CVS exited normally with code 1*****
cvs -z9 diff FieldHandlerImpl.java (in directory D:
\castor9_3_19\castor_current\castor\src\main\org\exolab\castor\mapping\loader\)
Index: FieldHandlerImpl.java
===================================================================
RCS file:
/cvs/castor/castor/src/main/org/exolab/castor/mapping/loader/FieldHandlerImpl.java,v
retrieving revision 1.42
diff -r1.42 FieldHandlerImpl.java
777a778,781
> //---- pmv
> //---- please, as a convenience
> public Method getReadMethod() {return _getMethod;}
>
*****CVS exited normally with code 1*****
cvs -z9 commit -m "added getReadMethod()" FieldHandlerImpl.java (in
directory D:
\castor9_3_19\castor_current\castor\src\main\org\exolab\castor\mapping\loader\)
cvs [server aborted]: "commit" requires write access to the repository
*****CVS exited normally with code 1*****
As can be seen from the last cvs comment, I cannot commit the changes! Here
I need some direction/help.
A test case, rather ugly code, illustrates the usage.
(See attached file: pollux.zip)
The output xml before the fix is applied.
(See attached file: PolluxTestPreFix.xml)
The xml after the fix.
(See attached file: PolluxTestPostFix.xml)
Again, I cannot commit these changes - some direction would be appreciated.
pollux.zip
Description: Zip archive
PolluxTestPreFix.xml
Description: Binary data
PolluxTestPostFix.xml
Description: Binary data
