Skip to content

to_xml: How to Add a Namespace to the Root Element Only #223

@sshaw

Description

@sshaw

In most cases the namespace only applies to the root element but outputting this sort of XML does not seem possible. For example, given this schema one must output the following:

<ns1:Transmission xmlns:ns1="https://ldex.limra.com/xsd/1.0/LDExBEM">
  <TransmissionGUID>1234106c-d731-466a-8235-3377985285yy</TransmissionGUID>
  <!-- ... -->
</ns1:Transmission>

Now How to achieve this? The namespace method is used "if a node and all its children are all namespaced elements".

The tag method does not accept a namespace argument like element method does. Specifying:

element :transmission_guid, String, :tag => "TransmissionGUID", :namespace => nil

or :namespace => false does not prevent the namespace provided to namespace from being output.

Does not seem possible to output a namespace only on the root element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions