Data Elements with both node and xsi:type Attributes

From RuleML Wiki
Jump to: navigation, search
--WikiSysop (talk) 11:25, 15 May 2014 (ADT)

1 Issue Description

With the addition of the @node attribute, which is allowed on Data elements, there is a problem when we want to use both the node labelling (@node) and explicit datatyping (xsi:type). This occurs because the XSD datatypes encompass the entire type of the element which including attributes as well as content. So it is not correct to have the following (which occurs in and :

  <RuleML xmlns=""
    <Data node="#d1" xsi:type="xs:integer">12</Data>

In Version 1.0 (and carried forward to Version 1.01) , the issue was partially resolved by constructing the Relax NG schema so that RuleML datatypes (e.g. ruleml:integer) could be used. However, in the XSD schemas this approach requires the definition of these types, and this has not been done. Also, a better long-term solution is needed that avoids the duplication of the XSD datatypes.

2 Options

2.1 Option 1

Keep the Relax NG schema as is, and improve the generated XSD schemas:

  <RuleML xmlns=""
    <Data node="#d1" xsi:type="integer">12</Data>

2.2 Option 2

Based on the approach taken in the metamodel of LegalRuleML where a symbol property is introduced to relate the Data object to its literal: The XML syntax for this is already part of XCL2, e.g.

   <Data ...other attributes>
     <symbol xsi:type="xsd:integer">12</symbol>

This approach also allows the use of other child elements, e.g. <meta> for annotations. Also, it would allow the use of xml:id on the edge to label the relationship. The edge would be skippable (with the type info placed on the parent ), so the syntax could maintain backward-compatibiity. However, it might be a good idea to deprecate the specially-defined ruleml datatypes that were introduced as a stop-gap measure in Deliberation RuleML 1.01.

3 Discussion

3.1 Harmonization

There needs to be a uniform solution for this issue in the harmonization of Deliberation and Reaction RuleML. The symbol edge described in Option 2 is important for LegalRuleML because of their pervasive use of xml:id on edges to label triples in the RDF-based serialization. So if this edge is not included in Deliberation/Reaction RuleML 1.02, it will have to be introduced in LegalRuleML as an extension.

4 Resolution

The pull request resolves this issue for Deliberation RuleML 1.01, but the issue still affects Version 1.0, and a long-term solution still needs to be chosen, with deprecation of the ruleml datatypes.

4.1 Relax NG Modules

A local soft link was created under the relaxng/test directory pointing to relaxng/modules.

This allows local testing of the rnc schemas without duplication of the modules directory.

4.2 Relax NG Drivers

Modified the bash script that downloads rnc for local testing to place the downloads into relaxng/test. This allows us to git-ignore the relaxng/test directory.

4.3 MYNG Engine




4.5 XSDs

An XSD schema containing the complexType definitions was placed in the (new) /datatypes directory. The generated XSDs were transformed using the modified XSLT to xs:include the datatypes schema.

4.6 Examples and Unit Tests

The exa/Datalog/datalog.ruleml examples was modified to refer to the ruleml:integer datatype in the case of the <Data> element with @node attribute.

Also, a variation of this example, datalog-ruleml.ruleml was added that uses prefix "ruleml" for the ruleml namespace. In this case the Data element becomes

  <ruleml:RuleML xmlns:ruleml=""
    <ruleml:Data node="#d1" xsi:type="ruleml:integer">12</ruleml:Data>

A new test/exa/Datalog directory was created by duplication of exa/Datalog and the global find/replace on URLS, so that the instances will be validated against local copies of the schemas.

Some cases of positional freedom were modified so that they would validate against the XSD.

4.7 XSLTs

The 101_rnc2xsd.xslt stylesheet was modified to insert an xs:include referencing the datatypes XSD schema into schemas whose target namespace is the RuleML namespace.

5 References