<?xml version="1.0" encoding="US-ASCII"?>
<!--xml2rfc v2 used-->
<!DOCTYPE rfc SYSTEM "rfc2629.dtd">
<?rfc rfcedstyle="yes"?>
<?rfc compact="yes" ?>
<?rfc subcompact="no" ?>
<?rfc toc="yes" ?>
<?rfc sortrefs="yes" ?>
<?rfc symrefs="yes" ?>
<rfc category="info" ipr="trust200902" number="7111" updates="4180" submissionType="independent">
	<front>
		<title abbrev="text/csv Fragment Identifiers">URI Fragment Identifiers for the text/csv Media Type</title>
		<author initials="M." surname="Hausenblas" fullname="Michael Hausenblas">
			<organization>DERI, NUI Galway</organization>
			<address>
				<postal>
					<street>IDA Business Park</street>
					<city>Galway</city>
					<country>Ireland</country>
				</postal>
				<phone>+353-91-495730</phone>
				<email>michael.hausenblas@deri.org</email>
				<uri>http://sw-app.org/about.html</uri>
			</address>
		</author>
		<author initials="E." surname="Wilde" fullname="Erik Wilde">
			<organization>EMC Corporation</organization>
			<address>
            <postal>
               <street>6801 Koll Center Parkway</street>
               <city>Pleasanton, CA 94566</city>
               <country>U.S.A.</country>
            </postal>
            <phone>+1-925-6006244</phone>
            <email>erik.wilde@emc.com</email>
            <uri>http://dret.net/netdret/</uri>
         </address>
		</author>
		<author initials="J." surname="Tennison" fullname="Jeni Tennison">
			<organization>Open Data Institute</organization>
			<address>
				<postal>
					<street>65 Clifton Street</street>
					<city>London EC2A 4JE</city>
					<country>U.K.</country>
				</postal>
				<phone>+44-797-4420482</phone>
				<email>jeni@jenitennison.com</email>
				<uri>http://www.jenitennison.com/blog/</uri>
			</address>
		</author>
		<date month="January" year="2014"/>

<!-- [rfced] Please insert any keywords (beyond those that appear in 
the title) for use on http://www.rfc-editor.org/search/rfc_search.php.
-->

		<abstract>
			<t>This memo defines URI fragment identifiers for text/csv MIME entities. These fragment identifiers make it possible to refer to parts of a text/csv MIME entity identified by row, column, or cell. Fragment identification can use single items or ranges.</t>
		</abstract>

<!-- [rfced] FYI, before publication, the "IESG Note" will be placed
below the "Status of This Memo" per the RFC Style Guide. (This placement
is not currently possible using xml2rfc.)
-->

<note title="IESG Note">
<t>
The change to the text/csv media type registration requires IESG approval, as
the IESG is the change controller for that registration.  The IESG has, after
consultation with the IETF community, approved the change, which is specified
in Section 5 of this document.
</t>
</note>
	</front>
	<middle>
		<section title="Introduction" anchor="intro">
			<t>This memo updates the text/csv media type defined in RFC 4180 <xref target="RFC4180"/> by defining URI fragment identifiers for text/csv MIME entities.</t>
			<t>The change to the text/csv media type registration required IESG approval, as the IESG is the change controller for that registration. The IESG has, after consultation with the IETF community, approved the change, which is specified in <xref target="IANA"/> of this document.</t>
			<t>This section gives an introduction to the general
concepts of text/&wj;csv MIME entities and URI fragment identifiers and discusses the need for fragment identifiers for text/csv and deployment issues. <xref target="methods"/> discusses the principles and methods on which this memo is based. <xref target="syntax"/> defines the syntax, and <xref target="processing"/> discusses processing of text/csv fragment identifiers.</t>
			<section title="What is text/csv?" anchor="what">
				<t>Internet Media Types (often referred to as
"MIME types") as defined in RFC 2045 <xref target="RFC2045"/> and RFC 2046
<xref target="RFC2046"/> are used to identify different types and subtypes of
media. The text/csv media type is defined in RFC 4180 <xref target="RFC4180"/>,
using US-ASCII <xref target="ASCII"/> as the default character encoding (other
character encodings can be used as well). Apart from a media type parameter for
specifying the character encoding ("charset"), there is a second media type parameter ("header") that indicates whether there is a header row in the CSV document or not.</t>
			</section>
			<section title="Why text/csv Fragment Identifiers?" anchor="why">
				<t>URIs are the identification mechanism for
resources on the Web.  The URI syntax specified in RFC 3986 <xref target="RFC3986"/> optionally includes a so-called "fragment identifier", separated by a number sign ("#"). The fragment identifier consists of additional reference information to be interpreted by the client after the retrieval action has been successfully completed. The semantics of a fragment identifier is a property of the media type resulting from a retrieval action, regardless of the URI scheme used in the URI reference. Therefore, the format and interpretation of fragment identifiers is dependent on the media type of the retrieval result.</t>

				<section title="Motivation" anchor="motivation">
					<t>Similar to the motivation in RFC
5147 <xref target="RFC5147"/>, which defines fragment identifiers for plain text
files, referring to specific parts of a resource can be very useful because it
enables users and applications to create more specific references. 

<!-- [rfced] May this sentence be revised for clarity as follows?

ORIGINAL:
   Users can create
   references to the part they really are interested in or want to talk
   about, rather than always pointing to a complete resource.

SUGGESTED:
   Users can create references to a particular point of interest within 
   a resource, rather than referring to the complete resource.
-->

Users can create references to the part they really are interested in or want to talk about, rather than always pointing to a complete resource. Even though it is suggested that fragment identification methods are specified in a media type's registration (see <xref target="RFC6838"/>), many media types do not have fragment identification methods associated with them.</t>
					<t>Fragment identifiers are only useful if supported by the client, because they are only interpreted by the client. Therefore, a new fragment identification method will require some time to be adopted by clients, and older clients will not support it. However, because the URI still works even if the fragment identifier is not supported (the resource is retrieved, but the fragment identifier is not interpreted), rapid adoption is not highly critical to ensure the success of a new fragment identification method.</t>
				</section>
				<section title="Use Cases" anchor="usecases">
					<t>Fragment identifiers for text/csv as defined in this memo make it possible to refer to specific parts of a text/csv MIME entity. Use cases include, but are not limited to, selecting a part for visual rendering, stream processing, making assertions about a certain value (provenance, confidence, comments, etc.), or data integration.</t>
			</section>
                       </section>
			<section title="Incremental Deployment" anchor="incremental">
				<t>As long as text/csv fragment identifiers are not supported universally, it is important to consider the implications of incremental deployment. Clients (for example, Web browsers) not supporting the text/csv fragment identifier described in this memo will work with URI references to text/csv MIME entities, but they will fail to understand the identification of the sub-resource specified by the fragment identifier, and thus will behave as if the complete resource was referenced. This is a reasonable fallback behavior and, in general users, should take into account the possibility that a program interpreting a given URI will fail to interpret the fragment identifier part. Since fragment identifier evaluation is local to the client (and happens after retrieving the MIME entity), there is no reliable way for a server to determine whether a requesting client is using a URI containing a fragment identifier.</t>
			</section>
			<section title="Notation Used in this Memo" anchor="notation">
				<t>The capitalized key words "MUST", "MUST NOT", "REQUIRED", "SHALL", "SHALL NOT", "SHOULD", "SHOULD NOT", "RECOMMENDED", "MAY", and "OPTIONAL" in this document are to be interpreted as described in RFC 2119 <xref target="RFC2119"/>.</t>
			</section>
                   </section>
		<section title="Fragment Identification Methods" anchor="methods">
			<t>This memo specifies fragment identification using
the following methods: "row" for row selections, "col" for columns selections, and "cell" for cell selections.</t>
			<t>Throughout the sections below, the following example table in CSV (having 7 rows, including one header row, and 3 columns) is used:</t>
			<figure>
				<artwork type="csv">date,temperature,place
2011-01-01,1,Galway
2011-01-02,-1,Galway
2011-01-03,0,Galway
2011-01-01,6,Berkeley
2011-01-02,8,Berkeley
2011-01-03,5,Berkeley</artwork>
			</figure>
			<section title="Row-Based Selection" anchor="method-row">
				<t>To select a specific record, the "row" scheme followed by a single number is used (the first row is at position 1).</t>
				<figure>
					<artwork type="uri">http://example.com/data.csv#row=4</artwork>
				</figure>
				<t>The above CSV fragment identifies the fourth row:</t>
				<figure>
					<artwork type="csv">2011-01-03,0,Galway</artwork>
				</figure>
				<t>Fragments can also select ranges of rows:</t>
				<figure>
					<artwork type="uri">http://example.com/data.csv#row=5-7</artwork>
				</figure>
				<t>The above CSV fragment identifies three consecutive rows:</t>
				<figure>
					<artwork type="csv">2011-01-01,6,Berkeley
2011-01-02,8,Berkeley
2011-01-03,5,Berkeley</artwork>
				</figure>
				<t>The value "*" can be used to indicate the last row, so the previous URI is equivalent to:</t>
				<figure>
					<artwork type="uri">http://example.com/data.csv#row=5-*</artwork>
				</figure>
                       </section>
			<section title="Column-Based Selection" anchor="method-column">
				<t>To select values from a certain column, the "col" scheme is used, followed by a position (the first column is at position 1):</t>
				<figure>
					<artwork type="uri">http://example.com/data.csv#col=2</artwork>
				</figure>
				<t>The above CSV fragment addresses the second column, identifying the column:</t>
				<figure>
					<artwork type="csv">temperature
1
-1
0
6
8
5</artwork>
				</figure>
				<t>The "col" scheme can also be used to identify ranges of columns:</t>
				<figure>
					<artwork type="uri">http://example.com/data.csv#col=1-2</artwork>
				</figure>
				<t>The above CSV fragment addresses the first and second column:</t>
				<figure>
					<artwork type="csv">date,temperature
2011-01-01,1
2011-01-02,-1
2011-01-03,0
2011-01-01,6
2011-01-02,8
2011-01-03,5</artwork>
				</figure>
				<t>As for rows, the value "*" can be used to indicate the last column.</t>
			</section>
			<section title="Cell-Based Selection" anchor="method-cell">
				<t>To select particular fields, the "cell" scheme is used, followed by a row number, a comma, and a column number.</t>
				<figure>
					<artwork type="uri">http://example.com/data.csv#cell=4,1</artwork>
				</figure>
				<t>The above CSV fragment addresses the field in the first column within the fourth row, yielding:</t>
				<figure>
					<artwork type="csv">2011-01-03</artwork>
				</figure>
				<t>It is also possible to select cell-based
fragments that have more than just one cell, in which case the cell selection
uses the same range syntax as for row and column range selections. For these
selections, the syntax uses the upper left-hand cell as the starting point of
the selection, followed by a minus sign, and then the lower right-hand cell as the end point of the selection.</t>
				<figure>
					<artwork>http://example.com/data.csv#cell=4,1-6,2</artwork>
				</figure>
				<t>The above CSV fragment selects a region that starts at the fourth row and the first column and ends at the sixth row and the second column:</t>
				<figure>
					<artwork type="csv">2011-01-03,0
2011-01-01,6
2011-01-02,8</artwork>
				</figure>
			</section>
			<section title="Multi-Selections" anchor="multi-select">
				<t>Row, column, and cell selections can make more than one selection, in which case the individual selections are separated by semicolons. In these cases, the resulting fragment may be a disjoint fragment, such as the selection "#row=3;6" for the example CSV, which would select the third and the sixth row. It is up to the user agent to decide how to handle disjoint fragments, but since they are allowed, user agents should be prepared to handle disjoint fragments.</t>
			</section>
                 </section>
		<section title="Fragment Identification Syntax" anchor="syntax">
			<t>The syntax for the text/csv fragment identifiers is as follows.</t>
			<t>The following syntax definition uses ABNF as defined in RFC 5234 <xref target="RFC5234"/>, including the rule DIGIT.</t>
			<t>
				<list style="hanging">
					<t hangText="NOTE:">In the descriptions that follow, specified text values MUST be used exactly as given, using exactly the indicated lowercase letters. In this respect, the ABNF usage differs from <xref target="RFC5234"/>.</t>
				</list>
			</t>
			<t>
				<figure>
					<artwork type="abnf">csv-fragment =  rowsel / colsel / cellsel
rowsel       =  "row=" singlespec 0*( ";" singlespec)
colsel       =  "col=" singlespec 0*( ";" singlespec)
cellsel      =  "cell=" cellspec 0*( ";" cellspec)
singlespec   =  position [ "-" position ]
cellspec     =  cellrow "," cellcol [ "-" cellrow "," cellcol ]
cellrow      =  position
cellcol      =  position
position     =  number / "*"
number       =  1*( DIGIT )</artwork>
				</figure>
			</t>
		</section>
		<section title="Fragment Identifier Processing" anchor="processing">
			<t>Applications implementing support for the mechanism described in this memo MUST behave as described in the following sections.</t>
			<section title="Syntax Errors in Fragment Identifiers" anchor="error-handling">
				<t>If a fragment identifier contains a syntax error (i.e., does not conform to the syntax specified in <xref target="syntax"/>), then it MUST be ignored by clients. Clients MUST NOT make any attempt to correct or guess fragment identifiers. Syntax errors MAY be reported by clients.</t>
			</section>
			<section title="Semantics of Fragment Identifiers" anchor="semantics">
				<t>Rows and columns in CSV are counted from
one. Positions thus refer to the rows and columns starting from position 1, which identifies the first row or column of a CSV. The special character "*" can be used to refer to the last row or column of a CSV, thus allowing fragment identifiers to easily identify ranges that extend to the last row or column.</t>
				<t>If single selections refer to non-existing rows or columns (i.e., beyond the size of the CSV), they MUST be ignored.</t>
				<t>If ranges extend beyond the size of the CSV
(by extending to rows or columns beyond the size of the CSV), they MUST be
interpreted to only extend to the actual size of the CSV.</t>

<!-- [rfced] May this be rephrased as follows for clarity?

Original:
   If selections of ranges of rows or columns or selections of cell
   ranges are specified in a way so that they select "inversely" (i.e.,
   "#row=10-5" or "#cell=10,10-5,5"), they MUST be ignored.

Perhaps:
   If selections of ranges of rows, ranges of columns, or ranges of
   cells are specified in a way so that they select "inversely" (i.e.,
   "#row=10-5" or "#cell=10,10-5,5"), they MUST be ignored.

Or:
   If selections of row ranges, column ranges, or cell ranges 
   are specified in a way so that they select "inversely" (i.e.,
   "#row=10-5" or "#cell=10,10-5,5"), they MUST be ignored.
-->

				<t>If selections of ranges of rows or columns or selections of cell
   ranges are specified in a way so that they select "inversely" (i.e.,
   "#row=10-5" or "#cell=10,10-5,5"), they MUST be ignored.</t>
				<t>Each specification of an identified region is processed independently, and ignored specifications (because of reasons listed in the previous paragraphs) do not cause the whole fragment identifier to fail, they just mean that this single specification is ignored. For the example file, the fragment identifier "#row=1-2;5-4;13-16" does identify the first two rows: the second specification is an "inverse" specification and thus is ignored, and the third specification targets rows beyond the actual size of the CSV and thus is also ignored.</t>
				<t>The complete fragment identifier identifies
all the successfully evaluated identified parts as a single identified
fragment. This fragment can be disjoint because of multiple
selections. Multiple selections also can result in overlapping individual parts, and it is up to the user agent how to process such a fragment and whether the individual parts are still made accessible (i.e., visualized in visual user agents) or are presented as one unit. For example, the fragment identifier "#row=3-6;4-5" contains a second identified part that is completely contained in the first identified part. Whether a user agent maintains this selection as two parts, or simply signals that the identified fragment spans from the third to the sixth row, is up for the user agent to decide.</t>
                   </section>		
	       </section>
		<section title="IANA Considerations" anchor="IANA">
<t>IANA has added a reference to this specification in the text/csv media type registration.</t>

			<section title="The text/csv media type" anchor="text-csv-registration">
				<t>The Internet media type <xref target="RFC6838"/> for a CSV document is text/csv. The following registration has been copied from the original registration of text/csv <xref target="RFC4180"/>, with the exception of the added fragment identification considerations and added security considerations for fragment identifiers.</t>
	                                  <t>				
                                       <list style="hanging">
						<t hangText="Type name:">text</t>
						<t hangText="Subtype name:">csv</t>
						<t hangText="Required parameters:">none</t>
						<t hangText="Optional parameters:">charset, header
			                        <list>
					<t>The "charset" parameter specifies the charset employed by the CSV content. In accordance with RFC 6657 <xref target="RFC6657"/>, the charset parameter SHOULD be used, and if it is not present, UTF-8 SHOULD be assumed as the default (this implies that US&nbhy;ASCII CSV will work, even when not specifying the "charset" parameter). Any charset defined by IANA for the "text" tree may be used in conjunction with the "charset" parameter.</t>
								<t>The "header" parameter indicates the presence or absence of the header line. Valid values are "present" or "absent". Implementors choosing not to use this parameter must make their own decisions as to whether the header line is present or absent.</t>
		  </list>
                 </t>
                                          <t hangText="Encoding considerations:">CSV MIME entities consist of binary data <xref target="RFC6838"/>. As per Section 4.1.1. of RFC 2046 <xref target="RFC2046"/>, this media type uses CRLF to denote line breaks. However, implementers should be aware that some implementations may use other values.</t>

                      				<t hangText="Security considerations:">
                                                 <list>
				<t>Text/csv consists of nothing but passive text data that should not pose any direct risks. However, it is possible that malicious data may be included in order to exploit buffer overruns or other bugs in the program processing the text/csv data.</t>
								<t>The text/csv
format provides no confidentiality or integrity protection, so if such protections are needed, they must be supplied externally.</t>
								<t>The fact that software implementing fragment identifiers for CSV and software not implementing them differs in behavior, and the fact that different software may show documents or fragments to users in different ways, can lead to misunderstandings on the part of users. Such misunderstandings might be exploited in a way similar to spoofing or phishing.</t>
								<t>Implementers and users of fragment identifiers for CSV text should also be aware of the security considerations in RFC 3986 <xref target="RFC3986"/> and RFC 3987 <xref target="RFC3987"/>.</t>
                                       </list>
						</t>
						<t hangText="Interoperability considerations:">Due to lack of a single specification, there are considerable differences among implementations. Implementers should "be conservative in what you do, be liberal in what you accept from others" (RFC 793 <xref target="RFC0793"/>) when processing CSV files. An attempt at a common definition can be found in Section 2. Implementations deciding not to use the optional "header" parameter must make their own decision as to whether the header is absent or present.</t>
						<t hangText="Published specification:">While numerous private specifications exist for various programs and systems, there is no single "master" specification for this format.  An attempt at a common definition can be found in Section 2 of RFC 4180 <xref target="RFC4180"/>.</t>
						<t hangText="Applications that use this media type:">Spreadsheet programs and various data conversion utilities.</t>
						<t hangText="Fragment identifier considerations:">Fragment identification for text/&wj;csv is supported by using fragment identifiers as specified by RFC 7111.</t>
                                            
						<t hangText="Additional information:">
					                 <list style="hanging">
								<t hangText="Magic number(s):">none</t>
								<t hangText="File extension(s):">CSV</t>
								<t hangText="Macintosh file type code(s):">TEXT</t>
                                                        </list>
                                              </t>  
    						<t hangText="Person &amp; email
address to contact for further information:">
<vspace blankLines="0"/>
Yakov Shafranovich &lt;ietf@shaftek.org> and
<vspace blankLines="0"/>
Erik Wilde &lt;dret@berkeley.edu></t>
						<t hangText="Intended usage:">COMMON</t>
						<t hangText="Restrictions on usage:">none</t>
						<t hangText="Author:">
<vspace blankLines="0"/>
Yakov Shafranovich &lt;ietf@shaftek.org> and
<vspace blankLines="0"/>
Erik Wilde &lt;dret@berkeley.edu></t>
						<t hangText="Change controller:">IESG</t>
                                           </list>
                                      </t>
                                </section>
                   	</section>
	<section title="Security Considerations" anchor="security">
			<t>The security considerations for text/csv fragment
identifiers are listed in the respective section of the media type registration
in <xref target="text-csv-registration"/>.</t>
              </section>
		<section title="Acknowledgements">
                   <t> Thanks for comments and suggestions provided by
Nevil Brownlee, Richard Cyganiak, Ian Davis, Gannon Dick, Leigh Dodds, and
Barry Leiba.</t>

</section>
</middle>
<back>
		<references title="Normative References">
                  <?rfc include="reference.RFC.2045"?>
                  <?rfc include="reference.RFC.2046"?>
               	  <?rfc include="reference.RFC.4180"?>
		  <?rfc include="reference.RFC.2119"?>
                  <?rfc include="reference.RFC.3986"?>
                  <?rfc include="reference.RFC.3987"?>

<!-- [rfced] RFC 4234 was obsoleted by RFC 5234, so we have updated 
the reference accordingly. Please let us know if you object.
-->

        	  <?rfc include="reference.RFC.5234"?>
	          <?rfc include="reference.RFC.6657"?>
            </references>

	<references title="Informative References">
			<reference anchor="ASCII">
				<front>
					<title>Coded Character Set - 7-Bit American National Standard Code for Information Interchange</title>
					<author>
						<organization>ANSI X3.4-1986</organization>
					</author>
					<date year="1992"/>
				</front>
				<seriesInfo name="STD" value="63"/>
				<seriesInfo name="RFC" value="3629"/>
                       </reference> 

                       <?rfc include="reference.RFC.0793"?>			
                       <?rfc include="reference.RFC.5147"?>
                       <?rfc include="reference.RFC.6838"?>

 <!-- [rfced] The following reference has been removed because it was cited
only in the change log, which has been removed. Please let us know if you 
object.

   [RFC6982]  Sheffer, Y. and A. Farrel, "Improving Awareness of Running
              Code: The Implementation Status Section", RFC 6982, July
              2013.
-->

</references>



	</back>
</rfc>
