Skip to content

Add support for adding attributes to output for root element #90

@cowtowncoder

Description

@cowtowncoder

(note: inspired by http://stackoverflow.com/questions/21086717/how-to-convert-pojo-to-xml-with-jackson)


It would make sense to be able to indicate that a specific XML Schema instance would be output as, say:

<TestUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="testUser.xsd">

or

<TestUser xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="testUserNoNs.xsd">

This should be done using new (in 3.2) XmlGeneratorInitializer, allowing arbitrary Attributes to be added to the root element, including XMLSchema-instance ones (but not just those): specifying:

  1. Attribute name as QName
  2. Attribute value as String

plus allowing String convenience overload for name (so 2 methods).

Attribute name/value combination to be stored as new RootAttribute value class which extends XmlGeneratorWritable.

Metadata

Metadata

Assignees

No one assigned

    Labels

    3.2adding-declarationsIssues related to adding non-content declarations to XML output

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions