ConceptioArchiveW3C TR
W3C TRopen access

rdf sparql XMLres

W3C · w3c_tr
W3C TR · Standards · License: Open Access
Open Source ↗
w3c, standard

SPARQL Query Results XML Format (Second Edition) /**/ span.cvs-id {color: gray; font-size:80%}

.toc { text-indent: 0; } DIV.toc UL UL, DIV.toc OL OL {margin-left: 0} DIV.toc UL UL UL, DIV.toc OL OL OL {margin-left: 1em} DIV.toc UL UL UL UL, DIV.toc OL OL OL OL {margin-left: 0} LI.tocline1 {font-weight: bold} LI.tocline2 {font-weight: normal} LI.tocline4 {font-style: italic} /* DIV.subtoc UL, DIV.subtoc OL {list-style: none} */ /* The border in the following rule crashes NN4 on fonts.html :-( DIV.subtoc {padding: 1em; border: solid black thin; margin: 1em 0; background: #ddd} */ DIV.toc, UL.index, DT { text-align: left }

PRE.xmlresult { margin: 1em 4em 1em 4em; color: black; background-color: #eee; padding: 0.5em; border-color: #006; border-width: 1px; border-style: dotted; }

DIV.mime { margin: 1em 4em 1em 4em; color: black; background-color: white; padding: 0.5em; border-color: black; border-width: 1px; border-style: solid; }

.defn { /*border: double 1px #888888; *//* Buggy */ border: 2px solid #888888; padding: 1ex 2ex 0.5ex 2ex ; /* top, right, bottom, left */ margin: 1em 6em 1em 2em ; page-break-inside: avoid ; background-color: #F0F8F8 ; } div.defn p { margin-top: 1ex ; margin-bottom: 1.5ex ;} div.defn ul { margin-top: 1ex ; margin-bottom: 1.5ex ;} span.definedTerm {font-weight: bold;}

.issue { color: #ff3f3f } ul.issue {} .note { margin-left: 2.5em; margin-right: 4ex ; font-size: 85% ; font-style: italic ; }

/**/ SPARQL Query Results XML Format (Second Edition) W3C Recommendation 21 March 2013 This version: http://www.w3.org/TR/2013/REC-rdf-sparql-XMLres-20130321/ Latest version: http://www.w3.org/TR/rdf-sparql-XMLres/ Previous version: http://www.w3.org/TR/2012/PER-rdf-sparql-XMLres-20121108/ Previous Recommendation: http://www.w3.org/TR/2008/REC-rdf-sparql-XMLres-20080115/ Second Edition Editor: Sandro Hawke Editors: Dave Beckett Institute for Learning and Research Technology (ILRT) University of Bristol Jeen Broekstra, Information Systems Group Eindhoven University of Technology Please refer to the errata See also translations Copyright W3C ® MIT ERCIM Keio Beihang liability trademark document use Abstract RDF is a flexible, extensible way to represent information about World Wide Web resources. It is used to represent, among other things, personal information, social networks, metadata about digital artifacts like music and images, as well as provide a means of integration over disparate sources of information. A standardized query language for RDF data with multiple implementations offers developers and end users a way to write and to consume the results of queries across this wide range of information. This document describes an XML format for the variable binding and boolean results formats provided by the SPARQL W3C RDF Data Access Working Group Semantic Web Activity activity statement Status of This Document May Be Superseded This section describes the status of this document at the time of its publication. Other documents may supersede this document. A list of current W3C publications and the latest revision of this technical report can be found in the W3C technical reports index Set of Documents This document is one of eleven SPARQL 1.1 Recommendations produced by the SPARQL Working Group SPARQL 1.1 Overview SPARQL 1.1 Query Language SPARQL 1.1 Update SPARQL1.1 Service Description SPARQL 1.1 Federated Query SPARQL 1.1 Query Results JSON Format SPARQL 1.1 Query Results CSV and TSV Formats SPARQL Query Results XML Format (Second Edition) SPARQL 1.1 Entailment Regimes SPARQL 1.1 Protocol SPARQL 1.1 Graph Store HTTP Protocol No Substantive Changes There have been no substantive changes to this document since the previous version change log color-coded diff Please Send Comments Please send any comments to [email protected] public archive SPARQL Working Group errata [email protected] public archive Endorsed By W3C This document has been reviewed by W3C Members, by software developers, and by other W3C groups and interested parties, and is endorsed by the Director as a W3C Recommendation. It is a stable document and may be used as reference material or cited from another document. W3C's role in making the Recommendation is to draw attention to the specification and to promote its widespread deployment. This enhances the functionality and interoperability of the Web. Patents This document was produced by a group operating under the 5 February 2004 W3C Patent Policy public list of any patent disclosures Essential Claim(s) section 6 of the W3C Patent Policy Table of Contents 1. Introduction 2. Definition 2.1. Document Element 2.2. Header 2.3. Results 3. Examples 4. XML Schemas 5. Internet Media Type, File Extension and Macintosh File Type 6. References 1. Introduction The SPARQL Query Language for RDF [SPARQL-QUERY] Query Result Forms SPARQL Query section 10 SPARQL Results Document SELECT SPARQL Query section 10.2 ASK SPARQL Query section 10.5 XML [XML] There are two other results formats which follow a similar design but do not use XML: SPARQL 1.1 Query Results JSON Format SRJ SPARQL 1.1 Query Results CSV and TSV Formats SRC 2. Definition Definition: SPARQL Results Document A SPARQL Results Document Section 4. 2.1. Document Element The SPARQL Results Document sparql http://www.w3.org/2005/sparql-results# <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> ... </sparql> Inside the sparql head results boolean 2.2. Header The head sparql For a variable binding query result, head Query Variable Solution Sequence The order of the variable names in the sequence is the order of the variable names given to the argument of the SELECT SELECT * Inside the head variable name <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#">

<head> <variable name="x"/> <variable name="hpage"/> <variable name="name"/> <variable name="mbox"/> <variable name="blurb"/> </head> ... </sparql> For a boolean query result, no elements are required inside head variable For any query result, head link href link variable <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#">

<head> ... <link href="metadata.rdf"/> </head> ... </sparql> 2.3. Results The second child-element of sparql head results boolean 2.3.1. Variable Binding Results The results For each Query Solution result results <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> ... head ...

<results> <result>... </result> <result>... </result> ... </results>

</sparql> Each result Query Solution Query Variable RDF Term Each binding inside a solution is written as an element binding result name x hpage <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> <head> <variable name="x"/> <variable name="hpage"/> </head>

<results> <result> <binding name="x"> ... </binding> <binding name="hpage"> ... </binding> </result>

<result> <binding name="x"> ... </binding> <binding name="hpage"> ... </binding> </result> ... </results>

</sparql> The value of a query variable binding, which is an RDF Term binding RDF URI Reference U <binding><uri> U </uri></binding> RDF Literal S <binding><literal> S </literal></binding> RDF Literal S L <binding><literal xml:lang=" L "> S </literal></binding> RDF Typed Literal S D <binding><literal datatype=" D "> S </literal></binding> Blank Node label I <binding><bnode> I </bnode></binding> If, for a particular solution, a variable is unbound binding result Note: I An example of a query solution encoded in this format is as follows: <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#">

<head> <variable name="x"/> <variable name="hpage"/> <variable name="name"/> <variable name="age"/> <variable name="mbox"/> <variable name="friend"/> </head>

<results>

<result> <binding name="x"> <bnode>r2</bnode> </binding> <binding name="hpage"> <uri>http://work.example.org/bob/</uri> </binding> <binding name="name"> <literal xml:lang="en">Bob</literal> </binding> <binding name="age"> <literal datatype="http://www.w3.org/2001/XMLSchema#integer">30</literal> </binding> <binding name="mbox"> <uri>mailto:[email protected]</uri> </binding> </result>

... </results>

</sparql> 2.3.2. Boolean Results A boolean result is written as the element content of a boolean sparql head true false <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#"> ... head ...

<boolean>true</boolean>

</sparql> 3. Examples 3.1. Variable Binding Results Examples An example SELECT example.rq data.n3 output.srx This XML can be transformed into XHTML using the sample XML Query script result-to-html.xq output-xquery.html result-to-html.xsl output-xslt.html 3.2. Boolean Results Examples An example ASK example2.rq data.n3 output2.srx This XML can be transformed into XHTML using the sample XML Query script result-to-html.xq output-xquery2.html result-to-html.xsl output-xslt2.html 4. XML Schemas There are normative XML schemas provided in the following formats: RELAX NG [RELAXNG] [RELAXNG-COMPACT] result.rnc RELAX NG XML in result.rng W3C XML Schema [XMLSCHEMA-1] result.xsd If W3C XML Schema is used, an xsi:schemaLocation <?xml version="1.0"?> <sparql xmlns="http://www.w3.org/2005/sparql-results#" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.w3.org/2007/SPARQL/result.xsd">

...

</sparql> 5. Internet Media Type, File Extension and Macintosh File Type The Internet Media Type / MIME Type for the SPARQL Query Results XML Format is "application/sparql-results+xml". It is recommended that result files have the extension ".srx" (all lowercase) on all platforms. It is recommended that result files stored on Macintosh HFS file systems be given a file type of "TEXT". Internet Media Type Registration Form Type name: application Subtype name: sparql-results+xml Required parameters: None Optional parameters: "charset": This parameter has identical semantics to the charset parameter of the "application/xml" media type as specified in [RFC3023] Encoding considerations: Identical to those of "application/xml" as specified in [RFC3023] Security considerations: SPARQL query results uses URIs. See Section 7 of [RFC3986] SPARQL query results uses IRIs. See Section 8 of [RFC3987] As this media type uses the "+xml" convention, it shares the same security considerations as described in [RFC3023] Interoperability considerations: There are no known interoperability issues. Published specification: This specification. Applications which use this media type: No known applications currently use this media type. Additional information: Magic number(s): As specified for "application/xml" in [RFC3023] File extension(s): ".srx" Fragment identifiers: Identical to that of "application/xml" as described in RFC 3023 [RFC3023] Base URI: As specified in [RFC3023] Macintosh file type code(s): "TEXT" Person & email address to contact for further information: Dave Beckett, Eric Prud'hommeaux <[email protected]> Intended usage: COMMON Restrictions on usage: None Author/Change controller: The SPARQL specification is a work product of the World Wide Web Consortium's RDF Data Access Working Group. The W3C has change control over these specifications. References [RFC3023] [RFC3986] [RFC3987] 6. References [XML] Extensible Markup Language (XML) 1.0, Third Edition latest version [SPARQL-QUERY] SPARQL 1.1 Query Language Latest version [RELAXNG] RELAX NG Specification latest version [RELAXNG-COMPACT] RELAX NG Compact Syntax [XMLSCHEMA-1] XML Schema Part 1: Structures Second Edition latest version [SRJ] SPARQL 1.1 Query Results JSON Format Latest version [SRC] SPARQL 1.1 Query Results CSV and TSV Formats Latest version Change Log Changes since Proposed Edited Recommendation Removed statement that IANA had not processed registration Changes since 2008 Recommendation Mention the JSON and CSV/TSV results formats Make in the examples point to maintainable versions

Related documents

Record · ID 19480 · SHA-256 1f63152d171fcd1f
Conceptio Open Knowledge Archive — every document is proof-bundled with source, license, and retrieval metadata.