Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » EclipseLink » Reading unspecified XML attributes with MOXy?(Using MOXy to read unspecified XML attributes with externalized metadata.)
Reading unspecified XML attributes with MOXy? [message #1726499] Mon, 14 March 2016 10:15
Michael Hillman is currently offline Michael HillmanFriend
Messages: 1
Registered: March 2016
Junior Member
I'm looking for a way to map all the attributes of an XML element into a single HashMap using MOXy (with an external OXM file) but I can't seem to find any information on it. I can't seem to find any references to dealing with multiple, unspecified attributes with either XmlAdapter instances or XmlTransformation instances.

If I have the below XML file and wish to marshal it into the below class, what would the best approach be?

Note that I can handle the "value" elements fine, it's the attributes I'm having trouble with; they should ideally map the XML attributes as...

[{"name", "firstElement"}, {"id", "idOne"}, {"author", "joeBloggs"}]


XML File:

<?xml version="1.0" encoding="UTF-8"?>
<root_node>
    <element name="firstElement" id="idOne" author="joeBloggs">
        <value>1</value>
        <value>2</value>
        <value>3</value>
    </element>
</root_node>


Java Class:

public class Element {

    public Map<String, String> attributes;

    public List<Integer> values;

    public List<String> getValues() {
        if(values == null) {
            values = new ArrayList<>();
        }
        return values;
    }

    public Map<String, String> getAttributes() {
        if(attributes == null) {
            attributes = new HashMap<>();
        }
        return attributes;
    }
}
Previous Topic:UpdateSite does not contain 2.6.2
Next Topic:java.lang.RuntimeException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.3.2.v2011
Goto Forum:
  


Current Time: Wed Mar 03 03:29:54 GMT 2021

Powered by FUDForum. Page generated in 0.02118 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top