Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support schema metadata #1

Open
maul-esel opened this issue Jul 12, 2013 · 0 comments
Open

Support schema metadata #1

maul-esel opened this issue Jul 12, 2013 · 0 comments

Comments

@maul-esel
Copy link
Member

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant