Uploaded image for project: 'Confluence Data Center'
  1. Confluence Data Center
  2. CONFSERVER-33424

Does not parse List<JaxbElement<?>> with a child element using custom XMLAdapter

    • We collect Confluence feedback from various sources, and we evaluate what we've collected when planning our product roadmap. To understand how this piece of feedback will be reviewed, see our Implementation of New Features Policy.

      NOTE: This suggestion is for Confluence Server. Using Confluence Cloud? See the corresponding suggestion.

      I am using Confluence-Jaxb version 2.1 (http://confluence.highsource.org/display/HJ3/JAXB) to generate Java beans for the XSD below. Java source code is properly generated but JAXB is not able to successfully unmarshal a valid XML file conforming to the XSD. I have provided below the XSD, my conformant XML file, and my Java code used to unmarshal.

      My specific problem is as below. I am using a custom Java class named com.tree.JAXBLeafNode for the element LeafNode in the XSD and have provided corresponding JaxB annotations to NOT generate Java beans for this element. I have also provided a custom XmlAdapter to marshal/unmarshal the element LeafNode. My custom marshal/unmarshaling handles converting the XML attributes appearing in the element LeafNode into some custom Java objects. LeafNode's parent element RootOrInnerNode, however, has the standard confluence-JAXB generated - Java beans. It has a List<JAXBElement<?>> to hold the contained LeafNode elements. It should be noted that, in the XSD, LeafNode's parent element RootOrInnerNode only contains the element AbstractNode as a direct child element and not the element LeafNode itself. LeafNode is rather indirectly rendered as a child of RootOrInnerNode since it is a substitution group for the element AbstractNode. Upon inspection using eclipse's debugger, I discovered that the List<JAXBElement<?>> in RootOrInnerNode contains a null for the LeafNodes. It appears that my custom XMLAdapter for the element LeafNode is not called, while instantiating its parent element RootOrInnerNode's JAXB bean and hence, the List<JAXBElement<?>> is not populated with the corresponding LeafNodes

      I have these constraints upon the XSD and custom Java bean,Adapter and marshal/unmarshall methods, while fixing this error. 1) I cannot change the schema. AbstractNode must exist the way it is in the XSD and both the RootOrInnerNode and LeafNode should have the existing associations with AbstractNode. This is the case since changing the XSD triggers lot bigger changes in several other parts of the project. 2) I must use custom Java beans named com.tree.JAXBLeafNode for the element LeafNode and a custom XMLAdapter since, I expect the binary data anyAttribute namespace=="##any" in the LeafNode element and do a lot of custom processing of this data.

      Would be of great help if I can obtain a way to generate the right LeafNode objects into the List<JAXBElement<?>> in RootOrInnerNode.

        1. JAXBLeafNode.java
          1 kB
          Venkatesh ChangeGowda
        2. JaxbTester.java
          2 kB
          Venkatesh ChangeGowda
        3. LeafNodeXMLAdapter.java
          2 kB
          Venkatesh ChangeGowda
        4. t_ARQ-schema-response-xacml3.0.xsd
          1 kB
          Venkatesh ChangeGowda
        5. try2.xml
          0.1 kB
          Venkatesh ChangeGowda

            [CONFSERVER-33424] Does not parse List<JaxbElement<?>> with a child element using custom XMLAdapter

            Hello - thank you for sending in this suggestion! Unfortunately, we do not have any plans to implement this in the foreseeable future. In order to set expectations correctly, we're closing this request now. If you'd like to describe more how this would help in your own use of Confluence, we may be able to provide better guidance.
            Thanks again for your idea, and please feel free to submit more!

            Regards,
            Confluence Product Management

            Simon Tan (Inactive) added a comment - Hello - thank you for sending in this suggestion! Unfortunately, we do not have any plans to implement this in the foreseeable future. In order to set expectations correctly, we're closing this request now. If you'd like to describe more how this would help in your own use of Confluence, we may be able to provide better guidance. Thanks again for your idea, and please feel free to submit more! Regards, Confluence Product Management

              Unassigned Unassigned
              4a9b820c92e1 Venkatesh ChangeGowda
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

                Created:
                Updated:
                Resolved: