SPARQL 1.1 Query Results CSV and TSV Formats .box { border: thin solid #888888; page-break-inside: avoid ; background-color: #F8F8F8 ; padding:1em ; }
pre { margin: 1em 4em 1em 2.5em ; /* Top Right Bottom Left */ padding: 1ex; page-break-inside: avoid ; }
pre.csv::before { content: "CSV" ; display: block; float: right ; width: 100px; background: #a0ffa0; font-family: sans-serif; font-size: 80% ; padding: 2px 2px 2px 20px ; font-weight: bold; margin: -1em 0 0.5em 1em; } pre.tsv::before { content: "TSV" ; display: block; float: right ; width: 100px; background: #a0ffa0; font-family: sans-serif; font-size: 80% ; padding: 2px 2px 2px 20px ; font-weight: bold; margin: -1em 0 0.5em 1em; }
table, td { border-spacing: 0px; padding: 0px ; border-collapse: collapse; text-align: left; } td, th { padding-left: 1em; padding-right: 1em; border-style: solid; border-width: 1px; border-color: black; border-bottom-color: gray; border-right-color: gray; } .result { border: thin solid #888888 ; background-color: #F0F0F0 ; } .tablecomment { border: 0 ; background-color: #FFFFFF ; } /***************************************************************** * ReSpec CSS * Robin Berjon (robin at berjon dot com) * v0.05 - 2009-07-31 *****************************************************************/
/* --- INLINES --- */ em.rfc2119 { text-transform: lowercase; font-variant: small-caps; font-style: normal; color: #900; }
h1 acronym, h2 acronym, h3 acronym, h4 acronym, h5 acronym, h6 acronym, a acronym, h1 abbr, h2 abbr, h3 abbr, h4 abbr, h5 abbr, h6 abbr, a abbr { border: none; }
dfn { font-weight: bold; }
a.internalDFN { color: inherit; border-bottom: 1px solid #99c; text-decoration: none; }
a.externalDFN { color: inherit; border-bottom: 1px dotted #ccc; text-decoration: none; }
a.bibref { text-decoration: none; }
code { color: #ff4500; }
/* --- WEB IDL --- */ pre.idl { border-top: 1px solid #90b8de; border-bottom: 1px solid #90b8de; padding: 1em; line-height: 120%; }
pre.idl::before { content: "WebIDL"; display: block; width: 150px; background: #90b8de; color: #fff; font-family: initial; padding: 3px; font-weight: bold; margin: -1em 0 1em -1em; }
.idlType { color: #ff4500; font-weight: bold; text-decoration: none; }
/*.idlModule*/ /*.idlModuleID*/ /*.idlInterface*/ .idlInterfaceID, .idlDictionaryID { font-weight: bold; color: #005a9c; }
.idlSuperclass { font-style: italic; color: #005a9c; }
/*.idlAttribute*/ .idlAttrType, .idlFieldType, .idlMemberType { color: #005a9c; } .idlAttrName, .idlFieldName, .idlMemberName { color: #ff4500; } .idlAttrName a, .idlFieldName a, .idlMemberName a { color: #ff4500; border-bottom: 1px dotted #ff4500; text-decoration: none; }
/*.idlMethod*/ .idlMethType { color: #005a9c; } .idlMethName { color: #ff4500; } .idlMethName a { color: #ff4500; border-bottom: 1px dotted #ff4500; text-decoration: none; }
/*.idlParam*/ .idlParamType { color: #005a9c; } .idlParamName { font-style: italic; }
.extAttr { color: #666; }
/*.idlConst*/ .idlConstType { color: #005a9c; } .idlConstName { color: #ff4500; } .idlConstName a { color: #ff4500; border-bottom: 1px dotted #ff4500; text-decoration: none; }
/*.idlException*/ .idlExceptionID { font-weight: bold; color: #c00; }
.idlTypedefID, .idlTypedefType { color: #005a9c; }
.idlRaises, .idlRaises a.idlType, .idlRaises a.idlType code, .excName a, .excName a code { color: #c00; font-weight: normal; }
.excName a { font-family: monospace; }
.idlRaises a.idlType, .excName a.idlType { border-bottom: 1px dotted #c00; }
.excGetSetTrue, .excGetSetFalse, .prmNullTrue, .prmNullFalse, .prmOptTrue, .prmOptFalse { width: 45px; text-align: center; } .excGetSetTrue, .prmNullTrue, .prmOptTrue { color: #0c0; } .excGetSetFalse, .prmNullFalse, .prmOptFalse { color: #c00; }
.idlImplements a { font-weight: bold; }
dl.attributes, dl.methods, dl.constants, dl.fields, dl.dictionary-members { margin-left: 2em; }
.attributes dt, .methods dt, .constants dt, .fields dt, .dictionary-members dt { font-weight: normal; }
.attributes dt code, .methods dt code, .constants dt code, .fields dt code, .dictionary-members dt code { font-weight: bold; color: #000; font-family: monospace; }
.attributes dt code, .fields dt code, .dictionary-members dt code { background: #ffffd2; }
.attributes dt .idlAttrType code, .fields dt .idlFieldType code, .dictionary-members dt .idlMemberType code { color: #005a9c; background: transparent; font-family: inherit; font-weight: normal; font-style: italic; }
.methods dt code { background: #d9e6f8; }
.constants dt code { background: #ddffd2; }
.attributes dd, .methods dd, .constants dd, .fields dd, .dictionary-members dd { margin-bottom: 1em; }
table.parameters, table.exceptions { border-spacing: 0; border-collapse: collapse; margin: 0.5em 0; width: 100%; } table.parameters { border-bottom: 1px solid #90b8de; } table.exceptions { border-bottom: 1px solid #deb890; }
.parameters th, .exceptions th { color: #fff; padding: 3px 5px; text-align: left; font-family: initial; font-weight: normal; text-shadow: #666 1px 1px 0; } .parameters th { background: #90b8de; } .exceptions th { background: #deb890; }
.parameters td, .exceptions td { padding: 3px 10px; border-top: 1px solid #ddd; vertical-align: top; }
.parameters tr:first-child td, .exceptions tr:first-child td { border-top: none; }
.parameters td.prmName, .exceptions td.excName, .exceptions td.excCodeName { width: 100px; }
.parameters td.prmType { width: 120px; }
table.exceptions table { border-spacing: 0; border-collapse: collapse; width: 100%; }
/* --- TOC --- */ .toc a { text-decoration: none; }
a .secno { color: #000; }
/* --- TABLE --- */ table.simple { border-spacing: 0; border-collapse: collapse; border-bottom: 3px solid #005a9c; }
.simple th { background: #005a9c; color: #fff; padding: 3px 5px; text-align: left; }
.simple th[scope="row"] { background: inherit; color: inherit; border-top: 1px solid #ddd; }
.simple td { padding: 3px 10px; border-top: 1px solid #ddd; }
.simple tr:nth-child(even) { background: #f0f6ff; }
/* --- DL --- */ .section dd > p:first-child { margin-top: 0; }
.section dd > p:last-child { margin-bottom: 0; }
.section dd { margin-bottom: 1em; }
.section dl.attrs dd, .section dl.eldef dd { margin-bottom: 0; }
/* --- EXAMPLES --- */ pre.example { border-top: 1px solid #ff4500; border-bottom: 1px solid #ff4500; padding: 1em; margin-top: 1em; }
pre.example::before { content: "Example"; display: block; width: 150px; background: #ff4500; color: #fff; font-family: initial; padding: 3px; font-weight: bold; margin: -1em 0 1em -1em; }
/* --- EDITORIAL NOTES --- */ .issue { padding: 1em; margin: 1em 0em 0em; border: 1px solid #f00; background: #ffc; }
.issue::before { content: "Issue"; display: block; width: 150px; margin: -1.5em 0 0.5em 0; font-weight: bold; border: 1px solid #f00; background: #fff; padding: 3px 1em; }
.note { margin: 1em 0em 0em; padding: 1em; border: 2px solid #cff6d9; background: #e2fff0; }
.note::before { content: "Note"; display: block; width: 150px; margin: -1.5em 0 0.5em 0; font-weight: bold; border: 1px solid #cff6d9; background: #fff; padding: 3px 1em; }
/* --- Best Practices --- */ div.practice { border: solid #bebebe 1px; margin: 2em 1em 1em 2em; }
span.practicelab { margin: 1.5em 0.5em 1em 1em; font-weight: bold; font-style: italic; }
span.practicelab { background: #dfffff; }
span.practicelab { position: relative; padding: 0 0.5em; top: -1.5em; }
p.practicedesc { margin: 1.5em 0.5em 1em 1em; }
@media screen { p.practicedesc { position: relative; top: -2em; padding: 0; margin: 1.5em 0.5em -1em 1em; } }
/* --- SYNTAX HIGHLIGHTING --- */ pre.sh_sourceCode { background-color: white; color: black; font-style: normal; font-weight: normal; }
pre.sh_sourceCode .sh_keyword { color: #005a9c; font-weight: bold; } /* language keywords */ pre.sh_sourceCode .sh_type { color: #666; } /* basic types */ pre.sh_sourceCode .sh_usertype { color: teal; } /* user defined types */ pre.sh_sourceCode .sh_string { color: red; font-family: monospace; } /* strings and chars */ pre.sh_sourceCode .sh_regexp { color: orange; font-family: monospace; } /* regular expressions */ pre.sh_sourceCode .sh_specialchar { color: #ffc0cb; font-family: monospace; } /* e.g., \n, \t, \\ */ pre.sh_sourceCode .sh_comment { color: #A52A2A; font-style: italic; } /* comments */ pre.sh_sourceCode .sh_number { color: purple; } /* literal numbers */ pre.sh_sourceCode .sh_preproc { color: #00008B; font-weight: bold; } /* e.g., #include, import */ pre.sh_sourceCode .sh_symbol { color: blue; } /* e.g., *, + */ pre.sh_sourceCode .sh_function { color: black; font-weight: bold; } /* function calls and declarations */ pre.sh_sourceCode .sh_cbracket { color: red; } /* block brackets (e.g., {, }) */ pre.sh_sourceCode .sh_todo { font-weight: bold; background-color: #00FFFF; } /* TODO and FIXME */
/* Predefined variables and functions (for instance glsl) */ pre.sh_sourceCode .sh_predef_var { color: #00008B; } pre.sh_sourceCode .sh_predef_func { color: #00008B; font-weight: bold; }
/* for OOP */ pre.sh_sourceCode .sh_classname { color: teal; }
/* line numbers (not yet implemented) */ pre.sh_sourceCode .sh_linenum { display: none; }
/* Internet related */ pre.sh_sourceCode .sh_url { color: blue; text-decoration: underline; font-family: monospace; }
/* for ChangeLog and Log files */ pre.sh_sourceCode .sh_date { color: blue; font-weight: bold; } pre.sh_sourceCode .sh_time, pre.sh_sourceCode .sh_file { color: #00008B; font-weight: bold; } pre.sh_sourceCode .sh_ip, pre.sh_sourceCode .sh_name { color: #006400; }
/* for Prolog, Perl... */ pre.sh_sourceCode .sh_variable { color: #006400; }
/* for LaTeX */ pre.sh_sourceCode .sh_italics { color: #006400; font-style: italic; } pre.sh_sourceCode .sh_bold { color: #006400; font-weight: bold; } pre.sh_sourceCode .sh_underline { color: #006400; text-decoration: underline; } pre.sh_sourceCode .sh_fixed { color: green; font-family: monospace; } pre.sh_sourceCode .sh_argument { color: #006400; } pre.sh_sourceCode .sh_optionalargument { color: purple; } pre.sh_sourceCode .sh_math { color: orange; } pre.sh_sourceCode .sh_bibtex { color: blue; }
/* for diffs */ pre.sh_sourceCode .sh_oldfile { color: orange; } pre.sh_sourceCode .sh_newfile { color: #006400; } pre.sh_sourceCode .sh_difflines { color: blue; }
/* for css */ pre.sh_sourceCode .sh_selector { color: purple; } pre.sh_sourceCode .sh_property { color: blue; } pre.sh_sourceCode .sh_value { color: #006400; font-style: italic; }
/* other */ pre.sh_sourceCode .sh_section { color: black; font-weight: bold; } pre.sh_sourceCode .sh_paren { color: red; } pre.sh_sourceCode .sh_attribute { color: #006400; } SPARQL 1.1 Query Results CSV and TSV Formats W3C This version: http://www.w3.org/TR/2013/REC-sparql11-results-csv-tsv-20130321/ Latest published version: http://www.w3.org/TR/sparql11-results-csv-tsv/ Previous version: http://www.w3.org/TR/PR-sparql11-results-csv-tsv-20121108/ Editor: Andy Seaborne Please refer to the errata See also translations Copyright W3C ® MIT ERCIM Keio Beihang liability trademark document use Abstract The formats CSV [ RFC4180 IANA-TSV SELECT 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. 1.1 2. 3. 3.1 3.2 3.3 4. 4.1 4.2 4.3 A. A.1 A.2 B. B.1 B.2 1. This document describes CSV and TSV formats for expressing the results of a SPARQL SELECT Other formats for expression SPARQL results are the SPARQL XML Results Format [ RDF-SPARQL-XMLRES SPARQL11-JSON-RES The SPARQL Results CSV Results Format is a lossy encoding of a table of results. It does not encode all the details of each RDF term in the results but instead just gives a string without indicating the type of the term (IRI, Literal, Literal with datatype, Literal with language, or blank node). This makes it simple to consume data, such as text and numbers, in applications without needing to understand the details of RDF. In some applications, guesses as to which elements are hyperlinks are made pragmatically, for example, guessing that strings starting "http://" are links. The SPARQL Results TSV Results Format does encode the details of RDF terms in the results table by using the syntax that SPARQL
[ SPARQL11-QUERY TURTLE When this document uses the words must must not should should not may recommended RFC2119 1.1 The following artificial example is used to illustrate the features of serializing results in each format. x literal Comment (not part of the table) <http://example/x> String An IRI and a string consisting of characters S-t-r-i-n-g <http://example/x> String-with-dquote" String with a double quote in it. _:b0 Blank node Blank node Missing 'x' No RDF term for the x This row has no terms in it. <http://example/x> No term in the literal _:b1 "String-with-lang"@en An RDF literal with a language tag _:b1 123 An RDF literal, datatype xsd:integer, and lexical form 123. 2. The SPARQL results formats described here confirm to the formal specifications of the relevant formats, Comma Separated values (CSV) [ RFC4180 IANA-TSV Systems providing these formats should note that the content types for CSV is text/csv text/tab-separated-values text/* charset should text/csv; charset=utf-8 text/tab-separated-values; charset=utf-8 The end-of-line in CSV is CRLF The end-of-line in TSV is EOL Applications reading these formats are advised to cope with both CRLF and LF as end of line markers and not rely on conformance to the formal specifications. 3. In the SPARQL Results CSV Format, the results table is serialized as one line listing the variables in the results, using the CSV header line, followed by one line for each query solution (a line may end up split by newlines in the data). Values in the results are strings, for URIs, literals and blank nodes, together with numbers when the literals are of numeric XSD datatype. 3.1 The first line of a SPARQL CSV Results Format response is the header line giving the names of the variables used in the result set. The header line consists of the variable names, without leading ? While the text/csv must header must header=present The remaining rows are the values of the results, with each binding determined by the position in the row, corresponding to the entry in the header line. If a variable is not bound, an empty field is used (e.g. ,, must 3.2 The entry in each field is the string corresponding to the RDF term value. (c.f. SPARQL STR()) without syntax to denote what kind of term it is. The encoding quoting rules of CSV format must be used. Blank nodes use the _:label Fields containing any of " QUOTATION MARK UNICODE , COMMA LF CR RFC4180 " " " "" The standard CSV format does not distinguish between missing values and empty strings. The SPARQL 1.1 CSV Results Format uses the same representation for unbound variables as for variables bound to an empty string literal. The other SPARQL Result formats (based on JSON, TSV or XML) can be used if this distinction is required. 3.3 x,literal http://example/x,String http://example/x,"String-with-dquote""" _:b0,Blank node ,Missing 'x' , http://example/x, _:b1,String-with-lang _:b1,123 4. In the SPARQL Results TSV Format, the results table is serialized as one line listing the variables in the results, followed by one line for each query solution. All RDF terms used in the format are encoded in the format specified by Turtle [ TURTLE must not \t \n \r 4.1 The results table is serialized as one line listing the variables in the results, followed by one line for each query solution. This first line is required by the TSV format [ IANA-TSV Variables are serialized in SPARQL syntax, using question mark ? Each row of the result set is serialized by sequence of RDF terms in SPARQL syntax, separated by a tab (Horizontal Tab, Unicode codepoint 9) character. If a variable is not bound in a row, an empty field is used. Each row must 4.2 The SPARQL Results TSV Results Format serializes RDF terms in the results table by using the syntax that SPARQL
[ SPARQL11-QUERY TURTLE IRIs enclosed in <...> " " ' ' @lang ^^ \t \n \r """ ''' must not The abbreviated forms for numbers (XSD integers, decimals and doubles) should Blank nodes use the _:label 4.3 Writing <TAB> ?x<TAB>?literal <http://example/x><TAB>"String" <http://example/x><TAB>"String-with-dquote\""
_:blank0<TAB>"Blank node" <TAB>"Missing 'x'" <TAB> <http://example/x><TAB> _:blank1<TAB>"String-with-lang"@en _:blank1<TAB>123 A. This section includes references not yet included in the standard biblio DB A.1 SPARQL11-JSON-RES SPARQL 1.1 Query Results JSON Format Latest version SPARQL11-QUERY SPARQL 1.1 Query Language Latest version A.2 Change Log Changes since Proposed Recommendation None Changes since Last Call None. B. B.1 [IANA-TSV] Paul Lindner. Definition of tab-separated-values (tsv) http://www.iana.org/assignments/media-types/text/tab-separated-values [RFC2119] S. Bradner. Key words for use in RFCs to Indicate Requirement Levels. http://www.ietf.org/rfc/rfc2119.txt [RFC4180] Y. Shafranovich. Common Format and MIME Type for Comma-Separated Values (CSV) Files http://www.ietf.org/rfc/rfc4180.txt [TURTLE] David Beckett, Tim Berners-Lee. Turtle: Terse RDF Triple Language. http://www.w3.org/TeamSubmission/turtle/ B.2 [RDF-SPARQL-XMLRES] Jeen Broekstra; Dave Beckett. SPARQL Query Results XML Format. http://www.w3.org/TR/2008/REC-rdf-sparql-XMLres-20080115 [UNICODE] The Unicode Consortium. The Unicode Standard. http://www.unicode.org/unicode/standard/versions/enumeratedversions.html