Skip to content

new RNC, RNG, XSD #7

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

Merged
merged 5 commits into from
Mar 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 97 additions & 0 deletions spec/result.rnc
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#
# RELAX NG Schema for SPARQL Query Results XML Format
#
# This XML schema is normative.
# $Id: result.rnc,v 1.1 2007/10/17 14:48:47 eric Exp $
# 2023-02-16 domel
#
#

namespace local = ""
namespace res = "http://www.w3.org/2005/sparql-results#"
namespace xsi = "http://www.w3.org/2001/XMLSchema-instance"
datatypes xsd = "http://www.w3.org/2001/XMLSchema-datatypes"


start = sparql

xmlLang = attribute xml:lang { text }

# Using xsi namespaced terms such as xsi:schemaLocation
# is tricky, as Relax requires them to be given when used. However,
# WXS has this knowledge built in and validators complain when they
# are explicitly listed without a schemaLocation (which is forbidden by
# the WXS spec).

xsiSchemaLoc = attribute xsi:schemaLocation { string }


sparql = element res:sparql {
xsiSchemaLoc?, head,
(results | boolean)
}

head = element res:head {
varName*, link*
}

varName = element res:variable {
nameAttr
}

nameAttr = attribute name {
xsd:NMTOKEN
}

hrefAttr = attribute local:href {
URI-reference
}

link = element res:link {
hrefAttr
}

results = element res:results {
result*
}


# ASK
boolean = element res:boolean {
xsd:boolean
}

# SELECT solution, single match or row
result = element res:result {
indexAttr?, binding*
}

# SELECT binding in a solution
binding = element res:binding {
nameAttr,
( uri | bnode | literal )
}

uri = element res:uri {
text
}

bnode = element res:bnode {
text
}

literal = element res:literal {
datatypeAttr?, xmlLang?,
text
}

indexAttr = attribute local:index {
xsd:positiveInteger
}

datatypeAttr = attribute local:datatype {
URI-reference
}

URI-reference = xsd:anyURI

142 changes: 142 additions & 0 deletions spec/result.rng
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

RELAX NG Schema for SPARQL Query Results XML Format

This XML schema is normative.
$Id: result.rng,v 1.1 2007/10/17 14:48:47 eric Exp $
2023-02-16 domel


-->
<grammar xmlns:res="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://relaxng.org/ns/structure/1.0" datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
<start>
<ref name="sparql"/>
</start>
<define name="xmlLang">
<attribute name="xml:lang"/>
</define>
<!--
Using xsi namespaced terms such as xsi:schemaLocation
is tricky, as Relax requires them to be given when used. However,
WXS has this knowledge built in and validators complain when they
are explicitly listed without a schemaLocation (which is forbidden by
the WXS spec).
-->
<define name="xsiSchemaLoc">
<attribute name="xsi:schemaLocation">
<data type="string" datatypeLibrary=""/>
</attribute>
</define>
<define name="sparql">
<element name="res:sparql">
<optional>
<ref name="xsiSchemaLoc"/>
</optional>
<ref name="head"/>
<choice>
<ref name="results"/>
<ref name="boolean"/>
</choice>
</element>
</define>
<define name="head">
<element name="res:head">
<zeroOrMore>
<ref name="varName"/>
</zeroOrMore>
<zeroOrMore>
<ref name="link"/>
</zeroOrMore>
</element>
</define>
<define name="varName">
<element name="res:variable">
<ref name="nameAttr"/>
</element>
</define>
<define name="nameAttr">
<attribute name="name">
<data type="NMTOKEN"/>
</attribute>
</define>
<define name="hrefAttr">
<attribute name="href">
<ref name="URI-reference"/>
</attribute>
</define>
<define name="link">
<element name="res:link">
<ref name="hrefAttr"/>
</element>
</define>
<define name="results">
<element name="res:results">
<zeroOrMore>
<ref name="result"/>
</zeroOrMore>
</element>
</define>
<!-- ASK -->
<define name="boolean">
<element name="res:boolean">
<data type="boolean"/>
</element>
</define>
<!-- SELECT solution, single match or row -->
<define name="result">
<element name="res:result">
<optional>
<ref name="indexAttr"/>
</optional>
<zeroOrMore>
<ref name="binding"/>
</zeroOrMore>
</element>
</define>
<!-- SELECT binding in a solution -->
<define name="binding">
<element name="res:binding">
<ref name="nameAttr"/>
<choice>
<ref name="uri"/>
<ref name="bnode"/>
<ref name="literal"/>
</choice>
</element>
</define>
<define name="uri">
<element name="res:uri">
<text/>
</element>
</define>
<define name="bnode">
<element name="res:bnode">
<text/>
</element>
</define>
<define name="literal">
<element name="res:literal">
<optional>
<ref name="datatypeAttr"/>
</optional>
<optional>
<ref name="xmlLang"/>
</optional>
<text/>
</element>
</define>
<define name="indexAttr">
<attribute name="index">
<data type="positiveInteger"/>
</attribute>
</define>
<define name="datatypeAttr">
<attribute name="datatype">
<ref name="URI-reference"/>
</attribute>
</define>
<define name="URI-reference">
<data type="anyURI"/>
</define>
<div xmlns="" id="divScriptsUsed" style="display: none"/><script xmlns="" id="globalVarsDetection" src="moz-extension://2adc9fc0-c0af-4a52-bfc7-3f0d5521bbcc/js/wrs_env.js"/></grammar>
105 changes: 105 additions & 0 deletions spec/result.xsd
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--

RELAX NG Schema for SPARQL Query Results XML Format

This XML schema is normative.
$Id: result.xsd,v 1.1 2007/10/17 14:48:47 eric Exp $
2023-02-16 domel


-->
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.w3.org/2005/sparql-results#" xmlns:res="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<xs:import namespace="http://www.w3.org/XML/1998/namespace" schemaLocation="http://www.w3.org/2001/xml.xsd"/>
<xs:attributeGroup name="xmlLang">
<xs:attribute ref="xml:lang" use="required"/>
</xs:attributeGroup>
<!--
Using xsi namespaced terms such as xsi:schemaLocation
is tricky, as Relax requires them to be given when used. However,
WXS has this knowledge built in and validators complain when they
are explicitly listed without a schemaLocation (which is forbidden by
the WXS spec).
-->
<xs:element name="sparql">
<xs:complexType>
<xs:sequence>
<xs:element ref="res:head"/>
<xs:choice>
<xs:element ref="res:results"/>
<xs:element ref="res:boolean"/>
</xs:choice>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="head">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="res:variable"/>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="res:link"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<xs:element name="variable">
<xs:complexType>
<xs:attributeGroup ref="res:nameAttr"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="nameAttr">
<xs:attribute name="name" use="required" type="xs:NMTOKEN"/>
</xs:attributeGroup>
<xs:attributeGroup name="hrefAttr">
<xs:attribute name="href" use="required" type="res:URI-reference"/>
</xs:attributeGroup>
<xs:element name="link">
<xs:complexType>
<xs:attributeGroup ref="res:hrefAttr"/>
</xs:complexType>
</xs:element>
<xs:element name="results">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="res:result"/>
</xs:sequence>
</xs:complexType>
</xs:element>
<!-- ASK -->
<xs:element name="boolean" type="xs:boolean"/>
<!-- SELECT solution, single match or row -->
<xs:element name="result">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" maxOccurs="unbounded" ref="res:binding"/>
</xs:sequence>
<xs:attribute name="index" type="xs:positiveInteger"/>
</xs:complexType>
</xs:element>
<!-- SELECT binding in a solution -->
<xs:element name="binding">
<xs:complexType>
<xs:choice>
<xs:element ref="res:uri"/>
<xs:element ref="res:bnode"/>
<xs:element ref="res:literal"/>
</xs:choice>
<xs:attributeGroup ref="res:nameAttr"/>
</xs:complexType>
</xs:element>
<xs:element name="uri" type="xs:string"/>
<xs:element name="bnode" type="xs:string"/>
<xs:element name="literal">
<xs:complexType mixed="true">
<xs:attribute name="datatype" type="res:URI-reference"/>
<xs:attribute ref="xml:lang"/>
</xs:complexType>
</xs:element>
<xs:attributeGroup name="indexAttr">
<xs:attribute name="index" use="required" type="xs:positiveInteger"/>
</xs:attributeGroup>
<xs:attributeGroup name="datatypeAttr">
<xs:attribute name="datatype" use="required" type="res:URI-reference"/>
</xs:attributeGroup>
<xs:simpleType name="URI-reference">
<xs:restriction base="xs:anyURI"/>
</xs:simpleType>
<div id="divScriptsUsed" style="display: none"/><script id="globalVarsDetection" src="moz-extension://2adc9fc0-c0af-4a52-bfc7-3f0d5521bbcc/js/wrs_env.js"/></xs:schema>