Skip to content

MOXy DynamicJAXBContext XML namespace attributes #2432

Open
@robinroos

Description

@robinroos

I am migrating a use-case from XML -> SaticJAXB -> MongoDocument to XML -> DynamicJAXB -> MongoDocument

DynamicJAXBContext dynamicContext = DynamicJAXBContextFactory.createContextFromXSD(xmlSchema, entityResolver, classLoader, properties);
JAXBUnmarshaller unmarshaller = dynamicContext.createUnmarshaller();
JAXBElement root = (JAXBElement) unmarshaller.unmarshal(xml);

In order to avoid information loss, so the same XML can be reconstitutes from the JSON/BSON data in mongodb, it is necessary that XML attributes also are persisted. In my case these are typically "xsi:noNamespaceSchemaLocation" and "xmlns:xsi".

At present those are not present in the Map<String, DynamicEntityImpl.PropertyWrapper> propertiesMap of the DynamicEntityImpl which is the value() of the JAXBElement representing the root node, nor are they available on the JAXBElement itself.

It would be most helpful if these XML attributes were added to the propertiesMap of the root node, perhaps governed by a new configuration property XML_INCLUDE_NAMESPACE_ATTRIBUTES.

FYI - I am finding MOXy to be extremely promising for this use-case.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions