Data Elements with both node and xsi:type Attributes
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 http://ruleml.org/1.0/exa/datalog.ruleml and http://deliberation.ruleml.org/1.01/exa/datalog.ruleml) :
<RuleML xmlns="http://ruleml.org/spec" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... <Data node="#d1" xsi:type="xs:integer">12</Data> ... </RuleML>
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.1 Option 1
Keep the Relax NG schema as is, and improve the generated XSD schemas:
- Add the definition of these types to the XSD schemas using xs:include. The XSLT stylesheet http://deliberation.ruleml.org/1.01/xslt/101_rnc2xsd.xslt can be used to add the include statement, while the included schema is manually written.
- Modify the example file http://deliberation.ruleml.org/1.01/exa/datalog.ruleml :
<RuleML xmlns="http://ruleml.org/spec" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... <Data node="#d1" xsi:type="integer">12</Data> ... </RuleML>
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> </Data>
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.
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.
The pull request https://github.com/RuleML/deliberation-ruleml/pull/60 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 web2rnc.sh 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.4 MYNG GUI
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="http://ruleml.org/spec" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> ... <ruleml:Data node="#d1" xsi:type="ruleml:integer">12</ruleml:Data> ... </ruleml:RuleML>
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.
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.