Skip to content

Clarify macro attributes ns and rename #83

Description

@valkum

Currently, there are no docs for the macro attributes. While the functions in instant-xml are pretty simple to understand, most of the magic happens in the derive macros.

For example:
Considering this:

#[derive(FromXml)]
struct Element {
#[xml(ns("other")]
field: ComplexType
}

#[derive(FromXml)]
#[xml(ns("namespace"))]
struct ComplexType {...}

What is the preferred way of setting a namespace or renaming?
You currently can set it on the type and on the field.

Working with instant-xml again raises the feeling that you should only set namespaces and renames on fields.
Defining a struct more or less is an implementation of an XML schema.

A schema can be defined like:

<element name="Element" type="elementType"/>
<complexType name="elementType">
        <sequence>
          <element name="reason" type="eppcom:reasonType"
            minOccurs="0"/>
        </sequence>
       <attribute name="state" type="someEnumType"
         default="after"/>
      </complexType>

The element reason would be namespaced by the namespace for the schema but uses a dataType defined in another schema.
Thus, it makes sense to derive name and namespace from the field or variant and not from the container.

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