Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
<element name="example">
 <complexType>
   <sequence>
     <element name="first" type="someComplexType"/>
     <sequence dfdldfdlx:attribute="attr1"/> <!-- gives schema declaration location of attribute data -->
     <element name="second" type="someOtherType"/>
     <sequence dfdldfdlx:attribute="attr2"/> <!-- this attribute is fourth in schema declaration order -->
   </sequence>
   <attribute name="attr1" type="xs:string" use="optional"/> <!-- optional == minOccurs=0, maxOccurs=1 -->
   <attribute name="attr2" type="xs:int" use="required"/> <!-- required == scalar -->
 </complexType>
</element>

<element name="exampleWithEmptyContent">
 <complexType> <!-- no sequences with dfdl:attribute property are needed -->
   <attribute name="attr1" type="xs:string" use="optional"/> <!-- optional == minOccurs=0, maxOccurs=1 -->
   <attribute name="attr2" type="xs:int" use="required"/> <!-- required == scalar -->
 </complexType>
</element>

Properties expressed on a sequence containing dfdldfdlx:attribute would be combined with properties expressed on an XSD attribute declaration.

A dfdldfdlx:attribute annotation element would be defined which can be added as an annotation element to an attribute declaration,  or attribute reference.

...

Attribute groups could also be supported via a dfdldfdlx:attributeGroup property on sequences.

This preserves the fact that the DFDL schema is still an XML logical schema, while still giving the schema-declaration order a meaning for a mixture of attribute and element children. The schema declaration order would be the order that the elements/attributes appear in, in the model group of the complex type.

Some caveats:

  • The QName/NCName given for the dfdlx:attribute="QName" must match an attribute, attribute group, attribute ref, or attribute group ref of that element.
  • A sequence with dfdldfdlx:attribute property cannot be a child of an XSD choice. It can only be the direct child of the sequence group that is the model group of a complex type.
  • DPath expressions need the "@" notation to name attributes.
  • DPath expressions would not allow indexing to retrieve attribute values e.g., ../@attr1[1] would be an SDE.
  • There is no need to allow simple content with attributes. Only empty content with attributes or element-only content with attributes need be supported.
  • Escaping - since attribute values are surrounded with quotation marks (single or double) in XML, those must be escaped if they appear in the content of the attribute value.

If an element has empty content and only attributes, then the need for sequences with the dfdl:attribute property is moot, and the attributes in their order of declaration will suffice to define the representation of the element type. So for small "tuple" like XML elements which have only attributes as children the schema remains simple and uncluttered.

An attribute can have dfdl:inputValueCalc, or dfdl:outputValueCalc, just like elements. An attribute can also