Skip to content

Write namespace declaration on root element only? #670

@carlanton

Description

@carlanton

Hello and thank you for such an awesome project!

I'm using dataformat-xml to create a video manifest (MPEG-DASH mpd), and for aesthetic reasons I'd really like if it could write all namespace declarations on the root element.

The XML I generate currently looks like this:

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd">
  <ContentProtection value="ClearKey1.0" schemeIdUri="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e">
    <dashif:Laurl xmlns:dashif="https://dashif.org/guidelines/clearKey">https://example.com/license</dashif:Laurl>
  </ContentProtection>
</MPD>

but I want to move the "xmlns:dashif="https://dashif.org/guidelines/clearKey"" to . Like this:

<MPD xmlns="urn:mpeg:dash:schema:mpd:2011"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:schemaLocation="urn:mpeg:dash:schema:mpd:2011 DASH-MPD.xsd"
     xmlns:dashif="https://dashif.org/guidelines/clearKey">
  <ContentProtection value="ClearKey1.0" schemeIdUri="urn:uuid:e2719d58-a985-b3c9-781a-b030af78d30e">
    <dashif:Laurl>https://example.com/license</dashif:Laurl>
  </ContentProtection>
</MPD>

Is it possible to configure / override something in XmlMapper or Woodstox to make this work?

Thanks a lot,
Anton

Java 21 with com.fasterxml.jackson.dataformat:jackson-dataformat-xml:2.17.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions