Great work on JiBX. It is the most flexible XML-Java binding framework
I've
ever seen AND the fastest. I hope to eliminate lots of homegrown code
and run
three to four times faster.
That said, I have one tricky problem I can't seem to solve. Consider the
following hypothetical classes
interface Xmlable {
}
class Foo implements Xmlable {
int fooStuff;
}
class Bar implements Xmlable {
float barStuff;
}
class FooBar implements Xmlable {
Xmlable xmlable;
}
class XmlableList implements Xmlable {
ArrayList xmlables;
}
and the related XML document below
<XmlableList>
<Foo>
<fooStuff>42<fooStuff/>
</Foo>
<Bar>
<barStuff>3.14<barStuff/>
</Bar>
<FooBar>
<AnyXmlable javaClass="Foo" >
<fooStuff>60<fooStuff/>
</AnyXmlable>
</FooBar>
<FooBar>
<AnyXmlable javaClass="Bar" >
<barStuff>2.72<barStuff/>
</AnyXmlable>
</FooBar>
</XmlableList>
which illustrate my problem.
Although each class which is marshalled to/from XML is typically
associated with
a uniquely named XML element, there are a few unfortunate instances of
element
AnyXmlable each of which corresponds to a Java object of the class
identified by
its javaClass attribute. The content of each AnyXmlable element depends
on its
actual type as determined by the javaClass attribute -- AnyXmlable
elements with
javaClass="Foo" contain fooStuff and AnyXmlable elements with
javaClass="Bar"
contain barStuff.
I can create a custom Unmarshaller for FooBar that creates an instance
of class Foo when it encounters <AnyXmlable javaClass="Foo" >, and I can
retrieve
the Unmarshaller for class Foo which knows how to deal with the
fooStuff contained by AnyXmlable. The problem is that the
Unmarshaller for class Foo relies on the fact that it is dealing with
a Foo element. When it sees that it is an AnyXmlable element it throws an
exception. I was hoping that some mechanism akin to IAliasable used for
custom
marshallers could be invoked, but the element names seem to be hard
coded into
the marshallers.
In reality, Foo and Bar correspond to hundreds Java classes and the
fooStuff and
barStuff can be quite complex and often highly recursive content. We
have tens
of thousands of historical documents containing a very small fraction of
AnyXmlable type elements which unfortunately we must support.
Can anyone suggest a means of patching over the AnyXmlable elements and
tying
back into the marshallers defined for all the Foo and Bar type classes?
Any suggestions are greatly appreciated.
Phil McGee
XFI Corp
-------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
_______________________________________________
jibx-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/jibx-users