• Type: New Feature New Feature
    • Status: Open Open
    • Priority: Major Major
    • Resolution: Unresolved
    • Affects Version/s: 1.3.1
    • Fix Version/s: None
    • Component/s: Converters
    • Labels:
    • JDK version and platform:
      jdk 1.5 for Mac OS X


      To recap: I want to be able to read documents that have defined objects, but some fields of the object contain arbitrary XML that I can't describe in advance. What I want is to be able to read and write these objects, and have these XML parts present in my program as XML trees represented as Dom or JDom or whatever.

      The last place I left it, I thought about the idea of having the XML object representation type being the type of the field – an org.w3c.xml.Element means a DOM document, an org.jdom.Element for a JDom object, etc. Since then I've implemented this idea and it works just fine for me. Here's what I've got:

      Two converters: DomConverter and JDomConverter that convert XML elements in a document into Dom or JDom object representations respectively. These must be used with matching drivers, because the "conversion" is simply using the document's current element.

      Jörg suggested that using the regular readers would cause problems because they don't handle mixed content (elements with mixed text and element children). That isn't a problem for me, and things work fine without worrying about that. However, I can imagine this is so, so I created MixedDomStreamReader and MixedJDomStreamReader classes. The specific converters (DomConverter and JDomConverter) return these kinds of readers from their createReader() methods. Marshalling uses a new MixedStreamCopier class to copy the node tree from the created mixed reader.

      I'm using this now, and it is working well for me. It works out to about 500 lines of code, and fundamentally seems robust.

      Note that this all assumes that reading is being done from in-memory document readers (dom, jdom) rather than stream-based ones (xpp, stax). Nothing about this precludes stream-based ones, as far as I can tell, but it would take some interesting work to do it.


        • Assignee:
          Jörg Schaible
          Ken Arnold
        • Votes:
          0 Vote for this issue
          1 Start watching this issue


          • Created: