Thanks Thomas. We started going down the CDATA route but ultimately just decided to use dom4j for the router section instead. The simplicity of dom4j/Xpath versus JiBX in this case was worth the slight performance hit. But we're still using JiBX outside the router in our services :)
Dave -----Original Message----- From: Thomas Jones-Low [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 16, 2006 1:31 PM To: jibx-users@lists.sourceforge.net Subject: Re: [jibx-users] Saving unknown sub-tags as strings using JiBX Feltenberger, David wrote: > All, > > I have an XML document that's subject to change fairly often, as it's going > to be used in a simple message router. The message format will look > something like what's included below. There's a repeating element called > MsgParts that has an attribute for identifying the type of message contained > inside, but I don't want to actually unmarshall the contents of the tag. I > want to save the XML inside each MsgParts tag as a String (the crux of the > problem). It's just going to get passed off to one or many destinations, > and outside of creating a CDATA and putting XML inside (which cries "Hack!" > to me), I can't figure out a way to do this with JiBX. And since it's > possible the MsgParts contents will change fairly often, I don't want to > re-compile/re-deploy the binding information each time we add a new type; I > have a database config of where/how types should get to their destination > but don't really care what's in the string I send. The ideal solution will > create a new MsgPart object (see below) and populate the fields in the class > appropriately. Any ideas? (Was that clear?) > > Thanks. > > Dave Feltenberger In the JiBX example/extras there are two items. One is the DiscardElementMapper.java, the other is the Dom4JMapper.java. The simple method is to adapt DiscardElementMapper.java to read the entire MsgPart tag into a string. The difficult part will be trying to write the string back, as JiBX will want to convert the angle brackets. For example, it will want to marshal to : <MsgParts type="test"> <test> <davetest>asdfasdf</davetest> </test> </MsgParts> There are three ways around this: Include it in a CDATA section, hack the JiBX code, or unmarshall it into DOM structure. The first you don't like, but it is the fastest. It may not be unmarshallable by the end code either. I've done the second in an earlier version of JiBX. Essentially you need to expose (make public) the IXMLWriter so you can write around the default methods of writing text. This was in an earlier version, and the changes required have changed. And I've lost them in the upgrades. The third you want to look at the Dom4JMapper.java and other related classes. It won't be pretty, but if you are not changing or looking at the data, it may work. -- Thomas Jones-Low Softstart Services Inc. [EMAIL PROTECTED] JobScheduler for Oracle Ph: 802-398-1012 http://www.softstart.com ------------------------------------------------------- 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 jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users "The sender believes that this E-mail and any attachments were free of any harmful and malicious code or defects when sent. This message and its attachments could have been infected during transmission. By reading the message and opening any attachments, the recipient accepts full responsibility for taking protective and remedial action regarding the code or such defects. The sender is not liable for any loss or damage arising in any way from this message or its attachments." ------------------------------------------------------- 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 jibx-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/jibx-users