Skip to content

Support schema metadata #1

Description

@maul-esel

Mapping raw data to XML is ambiguous. There may be data that can't be mapped, or the user may want it to be mapped differently.

To make it easier to define how the data should be mapped, allow metainformation to be placed inside the schema, in xsd:annotation/xsd:appInfo tags. Define the data that can be specified in a schema, and support reading and interpreting it.



As an example, take this schema fragment:

<xsd:complexType>
  <xsd:sequence>
    <xsd:element name="item" minOccurs="0" maxOccurs="unbounded">
      <xsd:complexType>
        <xsd:simpleContent>
          <xsd:extension base="xsd:string">
            <xsd:attribute use="required" type="xsd:string" name="key"/>
          </xsd:extension>
        </xsd:simpleContent>
      </xsd:complexType>
    </xsd:element>
  </xsd:sequence>
</xsd:complexType>

This should be mapped to the following data (here represented in JSON):

{
  "name" : "Frank",
  "job" : "-",
  "age" : 35
}

There's no defined way to map this. To solve the problem, the following metainfo would be placed in the xsd:sequence element:

<xsd:annotation>
  <xsd:appInfo>
    <meta:transform>
      <meta:hash-to-xml>
        <meta:key xpath="@key"/>
        <meta:value xpath="."/>
      </meta:hash-to-xml>
    </meta:transform>
  </xsd:appInfo>
</xsd:annotation>

These instructions would map the array to item elements, with the key as attribute and the value as element content:

<item key="name">Frank</item>
<item key="job">-</item>
<item key="age">35</item>

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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