Movatterモバイル変換


[0]ホーム

URL:


W3C

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 theerrata for this document, which may include some normative corrections.

See alsotranslations.

Copyright © 2013W3C® (MIT,ERCIM,Keio,Beihang), All Rights Reserved. W3Cliability,trademark anddocument use rules apply.


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 theSPARQL query language for RDF, developed by theW3C RDF Data Access Working Group (DAWG), part of theSemantic Web Activity as described in theactivity 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 theW3C technical reports index at http://www.w3.org/TR/.

Set of Documents

This document is one of eleven SPARQL 1.1 Recommendations produced by theSPARQL Working Group:

  1. SPARQL 1.1 Overview
  2. SPARQL 1.1 Query Language
  3. SPARQL 1.1 Update
  4. SPARQL1.1 Service Description
  5. SPARQL 1.1 Federated Query
  6. SPARQL 1.1 Query Results JSON Format
  7. SPARQL 1.1 Query Results CSV and TSV Formats
  8. SPARQL Query Results XML Format (Second Edition)
  9. SPARQL 1.1 Entailment Regimes
  10. SPARQL 1.1 Protocol
  11. SPARQL 1.1 Graph Store HTTP Protocol

No Substantive Changes

There have been no substantive changes to this document since theprevious version. Minor editorial changes, if any, are detailed in thechange log and visible in thecolor-coded diff.

Please Send Comments

Please send any comments topublic-rdf-dawg-comments@w3.org (public archive). Although work on this document by theSPARQL Working Group is complete, comments may be addressed in theerrata or in future revisions. Open discussion is welcome atpublic-sparql-dev@w3.org (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 the5 February 2004 W3C Patent Policy. W3C maintains apublic list of any patent disclosures made in connection with the deliverables of the group; that page also includes instructions for disclosing a patent. An individual who has actual knowledge of a patent which the individual believes containsEssential Claim(s) must disclose the information in accordance with section 6 of the W3C Patent Policy.


Table of Contents

1.Introduction

TheSPARQL Query Language for RDF[SPARQL-QUERY]defines severalQuery Result Forms(SPARQL Query section 10).This document defines aSPARQL Results Documentthat encodesthe variable binding query results fromSELECT queries(SPARQL Query section 10.2)and boolean query results fromASK queries(SPARQL Query section 10.5)inXML[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] andSPARQL 1.1 Query Results CSV and TSV Formats [SRC].

2. Definition

Definition:SPARQL Results Document

ASPARQL Results Document is an XML document that is valid with respect to either the RELAX NG XML Schema or the W3C XML Schema inSection 4.

2.1. Document Element

TheSPARQL Results Documentbegins withsparql document element in thehttp://www.w3.org/2005/sparql-results# namespace,written as follows:

<?xml version="1.0"?><sparql xmlns="http://www.w3.org/2005/sparql-results#"> ...</sparql>

Inside thesparql element are two sub-elements,head and a results element (eitherresults orboolean)which must appear in that order.

2.2. Header

Thehead element is the first child element ofthesparql element.

For a variable binding query result,head must contain asequence of elements describing the set ofQuery Variablenames in theSolution Sequence(here called query results).

The order of the variable names in the sequence is the order ofthe variable names given to the argument of theSELECTstatement in the SPARQL query. IfSELECT * is used, theorder of the names is undefined.

Inside thehead element, the ordered sequence ofvariable names chosen are used to create empty child elementsvariable with the variable name as the value of anattributename giving a document like this:

<?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 insidehead andvariable must not be present.

For any query result,head may also containlink child elements with anhref attributecontaining a relative URI that provides a link to some additionalmetadata about the query results. The relative URI is resolvedagainst the in-scope base URI which is usually the query resultsformat document URI.link elements must appear afteranyvariable elements that are present.

<?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 ofsparqlmust appear afterhead and is eitherresults orboolean.It is written even if the query results are empty.

2.3.1. Variable Binding Results

Theresults element contains the complete sequence ofquery results.

For eachQuery Solutionin the query results, aresultchild-element ofresults is added givinga document like:

<?xml version="1.0"?><sparql xmlns="http://www.w3.org/2005/sparql-results#">  ...  head ...  <results>    <result>...    </result>    <result>...    </result>    ...  </results></sparql>

Eachresult element corresponds to oneQuerySolution in a result and contains child elements (in no particular order) for eachQueryVariable that appears in the solution. Itis used to record how the query variables bind toRDFTerms.

Each binding inside a solution is written as an elementbinding as a child ofresult with the queryvariable name as the value of thename attribute. So for a result binding two variablesx andhpage it wouldlook like:

<?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 anRDF Term, isincluded as the content of thebinding as follows:

RDF URI ReferenceU
<binding><uri>U</uri></binding>
RDF LiteralS
<binding><literal>S</literal></binding>
RDF LiteralS with languageL
<binding><literalxml:lang="L">S</literal></binding>
RDF Typed LiteralS with datatype URID
<binding><literaldatatype="D">S</literal></binding>
Blank Node labelI
<binding><bnode>I</bnode></binding>

If, for a particular solution, a variable isunbound, nobinding element for that variable is included in theresult element.

Note: The blank node labelI is scopedto the result set XML document and need not have any association tothe blank node label for that RDF Term in the query graph.

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:bob@work.example.org</uri>      </binding>    </result>    ...  </results></sparql>

2.3.2. Boolean Results

A boolean result is written as the element content of aboolean child-element of thesparqlelement directly after ahead,containing eithertrue orfalse as follows:

<?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 exampleSELECT SPARQL Query inexample.rq operating on query graph Turtle/N3 data indata.n3 providing ordered variable binding query results written in XML inoutput.srx.

This XML can be transformed into XHTML using the sample XML Query scriptresult-to-html.xq givingoutput-xquery.html or with XSLT sheetresult-to-html.xsl givingoutput-xslt.html

3.2. Boolean Results Examples

An exampleASK SPARQL Query inexample2.rq operating on query graph Turtle/N3 data indata.n3 provides a boolean query result written in XML inoutput2.srx.

This XML can be transformed into XHTML using the sample XML Query scriptresult-to-html.xq givingoutput-xquery2.html or with XSLT sheetresult-to-html.xsl givingoutput-xslt2.html

4. XML Schemas

There are normative XML schemas provided in the following formats:

  1. RELAX NG[RELAXNG] Compact[RELAXNG-COMPACT] inresult.rnc
  2. RELAX NG XML inresult.rng
  3. W3C XML Schema[XMLSCHEMA-1] inresult.xsd
    Note: this schema is machine-generated from the RELAX NG XML schema.

If W3C XML Schema is used, anxsi:schemaLocationattribute can be used pointing to the schema as follows:

<?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 XMLFormat is "application/sparql-results+xml".

It is recommended that result files have the extension ".srx" (alllowercase) on all platforms.

It is recommended that result files stored on Macintosh HFS filesystems 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], section 3.2.
Encoding considerations:
Identical to those of "application/xml" as specified in[RFC3023], section 3.2.
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], section 10.

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], section 3.2.
File extension(s):
".srx"
Fragment identifiers:
Identical to that of "application/xml" as described in RFC 3023[RFC3023], section 5.
Base URI:
As specified in[RFC3023], section 6.
Macintosh file type code(s):
"TEXT"
Person & email address to contact for further information:
Dave Beckett, Eric Prud'hommeaux <public-rdf-dawg-comments@w3.org>
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] Murata, M., St. Laurent, S., and D. Kohn, "XML Media Types", RFC 3023, January 2001.

[RFC3986] Berners-Lee, T., Fielding, R., and L. Masinter, "Uniform Resource Identifier (URI): Generic Syntax", STD 66, RFC 3986, January 2005.

[RFC3987] Duerst, M. and M. Suignard, "Internationalized Resource Identifiers (IRIs)", RFC 3987, January 2005.

6. References

[XML]
Extensible Markup Language (XML) 1.0, Third Edition, T. Bray, J. Paoli, C.M. Sperberg-McQueen, E. Maler, F. Yergeau, Editors, W3C Recommendation, 4 February 2004. This document is http://www.w3.org/TR/2004/REC-xml-20040204 . Thelatest version is available at http://www.w3.org/TR/REC-xml .
[SPARQL-QUERY]
SPARQL 1.1 Query Language, S. Harris, A. Seaborne, Editors, W3C Recommendation, 21 March 2013, http://www.w3.org/TR/2013/REC-sparql11-query-20130321.Latest version available at http://www.w3.org/TR/sparql11-query.
[RELAXNG]
RELAX NG Specification, James Clark and MURATA Makoto, Editors, OASIS Committee Specification, 3 December 2001. This document is http://www.oasis-open.org/committees/relax-ng/spec-20011203.html . Thelatest version is available at http://www.oasis-open.org/committees/relax-ng/spec.html .
[RELAXNG-COMPACT]
RELAX NG Compact Syntax, James Clark, Editor. OASIS Committee Specification, 21 November 2002. This document is http://www.oasis-open.org/committees/relax-ng/compact-20021121.html .
[XMLSCHEMA-1]
XML Schema Part 1: Structures Second Edition, D. Beech, N. Mendelsohn, M. Maloney, H. S. Thompson, Editors, W3C Recommendation, 28 October 2004. This document is http://www.w3.org/TR/2004/REC-xmlschema-1-20041028/ . Thelatest version is available at http://www.w3.org/TR/xmlschema-1/ .
[SRJ]
SPARQL 1.1 Query Results JSON Format, A. Seaborne, Editor, W3C Recommendation, 21 March 2013, http://www.w3.org/TR/2013/REC-sparql11-results-json-20130321.Latest version available at http://www.w3.org/TR/sparql11-results-json.
[SRC]
SPARQL 1.1 Query Results CSV and TSV Formats, A. Seaborne, Editor, W3C Recommendation, 21 March 2013, http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321.Latest version available at http://www.w3.org/TR/sparql11-results-csv-tsv.

Change Log

Changes since Proposed Edited Recommendation

Changes since 2008 Recommendation


[8]ページ先頭

©2009-2025 Movatter.jp