/[fenfire]/fenfire/docs/pegboard/canon3_file_format--benja/peg.rst
ViewVC logotype

Diff of /fenfire/docs/pegboard/canon3_file_format--benja/peg.rst

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by benja, Tue Apr 1 19:46:07 2003 UTC revision 1.2 by benja, Wed Apr 2 14:03:30 2003 UTC
# Line 21  for storing versions of RDF graphs in St Line 21  for storing versions of RDF graphs in St
21  This PEG specifies such a format.  This PEG specifies such a format.
22    
23    
24    Issues
25    ======
26    
27    - Does this also cover bags and sequences? Reification?
28    
29       RESOLVED: Of course. All RDF structures (anything
30       that can be serialized as triples) can be
31       represented as Canon3.
32    
33    - Do we really need a new format?
34    
35       RESOLVED: None of the existing formats are canonical.
36    
37    - How compatible is this with N3 and NTriples?
38      What are the differences?
39    
40       RESOLVED: NTriples is encoded in US-ASCII and
41       doesn't allow for multi-line literals. N3 cannot
42       refer to anonymous nodes. An N3 processor
43       will be able to read any Canon3 file that does
44       not contain anonymous nodes (except if the
45       Unicode LINE SEPARATOR character is used,
46       which is not allowed by N3).
47    
48       (Anonymous nodes in Canon3 are represented
49       as in NTriples.)
50      
51    - Should the encoding allowed to be different?
52      
53       RESOLVED: No, since that would lose both
54       canonicality and compatibility with N3.
55    
56    - Is UTF-8 always sufficient?
57    
58       RESOLVED: UTF-8 can represent all of Unicode and
59       RDF uses Unicode only; therefore, yes.
60    
61    - Is quoting with three quotes really what we want?
62    
63       RESOLVED: Multiline literals is really what
64       we want-- imagine you have a 1K HTML document
65       as a literal and the encoder puts it all
66       in one line. (Also, with multiline literals,
67       CVS's diffs are more useful.)
68    
69       Multiline literals are enclosed in three quotes in N3.
70    
71    - Does the specification need to talk about equal triples
72      occuring in the same graph? Can the same triple
73      occur twice, according to the RDF spec?
74    
75       RESOLVED: There are tools which allow a single triple
76       to occur twice. Therefore, the spec should be clear
77       about the topic.
78    
79    - Why `Normalization Form C`_?
80    
81       RESOLVED: Because it's required by N3, and because
82       it's the standard on the Web (http://www.w3.org/TR/charmod/).
83    
84    - Does it allow for the different newline conventions?
85    
86       RESOLVED: Yes. (Normalization Form C only specifies that
87       composite characters like umlauts are stored in
88       composited, not decomposited form. See the spec.)
89    
90    - Wouldn't it be easier to produce the serialization format
91      for each triple, and then put those into lexical order?
92      Or if the parts must be compared
93      separately, could we compare serializations of those parts?
94    
95       RESOLVED: We assume that a Canon3 writer usually operates
96       on an in-memory representation of an RDF graph. That
97       makes it easy to sort triples in unencoded, and hard
98       to sort them in the encoded way. It's also more scalable:
99       Sorting on the serializations would mean having to
100       generate the whole serialization in memory first,
101       before writing anything to the disk.
102    
103       (Also note that simply sorting the *lines*
104       wouldn't work anyway, because of multiline literals.)
105    
106    
107  Specification  Specification
108  =============  =============
109    
# Line 39  They obey the following grammar:: Line 122  They obey the following grammar::
122      URItoken ::= "<" URIref ">"      URItoken ::= "<" URIref ">"
123      anonNode ::= "_:" [A-Za-z][A-Za-z0-9]*      anonNode ::= "_:" [A-Za-z][A-Za-z0-9]*
124      literal ::= #x22 #x22 #x22 string #x22 #x22 #x22 qualifiers      literal ::= #x22 #x22 #x22 string #x22 #x22 #x22 qualifiers
125      qualifiers ::= ("@" language)? ("^^" URItoken)?      qualifiers ::= ("@" language)? ("^^" type)?
126        type ::= URItoken
127    
128  The ``NEWLINE`` token may be any of CR, LF, and CRLF.  The ``NEWLINE`` token may be any of CR, LF, CRLF, and
129  (This is necessary for CVS to be useful across platforms.)  the Unicode LINE SEPARATOR (U+2028).
130    This is necessary for CVS, to be useful across platforms.
131  In contexts where the specific form used matters,  In contexts where the specific form used matters,
132  the newline character is LF. (In particular, when computing  the newline character is LF. (In particular, when computing
133  a content hash-- e.g., when creating a Canon3 Storm block.)  a content hash-- e.g., when creating a Canon3 Storm block.)
134    It would be nicer to use LINE SEPARATOR, but that
135    would be an incompatibility with N3.
136    
137    A ``string`` is any UTF-8 character sequence
138    encoded in the following way:
139    
140    - Double any backslash in the string.
141    - Insert a backslash before the first of any three
142      consecutive double quotes (#x22) in the string.
143      (This means: In a sequence of three or more
144      double quote characters, instert a backslash
145      before all but the last two double quotes).
146    
147    For example, the string ``f\oo"""""ba"r`` becomes
148    ``f\\oo\"\"\"""ba"r``.
149    
150    Strings may contain newlines. Like all of Canon3,
151    they are encoded in Normalization Form C.
152    They are enclosed in triple double quotes
153    (see production ``literal``).
154    
155  The triples must be ordered. Two triples are compared  The triples must be ordered. Two triples are compared
156  by comparing their subjects, properties, and objects  by comparing their subjects, properties, and objects
# Line 77  A triple may only be listed once; if the Line 182  A triple may only be listed once; if the
182  equal triples in the graph to be serialized, this  equal triples in the graph to be serialized, this
183  triple must occur only once in the serialization.  triple must occur only once in the serialization.
184    
185  ``URIref`` is a URI reference as defined in [RFC 2396].  ``URIref`` is one of the following:
 Percent escapes (e.g. ``%2f``) should preferably  
 be encoded in lower case. URIref may be either of the following:  
   
 1. An absolute URI (e.g., ``http://example.org/``).  
 2. An absolute URI plus a fragment identifier  
    (e.g., ``http://example.org/#foo``).  
 3. The empty URI reference (which is a relative URI  
    refering to the current document).  
 4. A standalone fragment identifier (e.g., ``#foo``),  
    refering to a fragment of the current document.  
186    
187  ``language`` is a Language-Tag as defined by [RFC 3066].  1. An `RDF URI reference`_ encoded in UTF-8 (Normalization
188       Form C) as the rest of Canon3.
189    2. An RDF URI reference with everything before the
190       fragment identifier (if any) omitted. This refers
191       to the current document (in the case of the empty
192       string) or to a fragment of it (e.g., ``#foo``).
193    
194  A ``string`` is any UTF-8 character sequence  ``language`` is a Language-Tag as defined by [RFC 3066].
195  encoded in the following way:  If present, ``language`` and ``type`` indicate
196    the `language tag and data type`_ of a literal.
 - Double any backslash in the string.  
 - Insert a backslash before the first of any three  
   consecutive double quotes (#x22) in the string.  
   (This means: In a sequence of three or more  
   double quote characters, instert a backslash  
   before all but the last two double quotes).  
197    
198  For example, the string ``f\oo"""""ba"r`` becomes  Here's an example Canon3 file::
 ``f\\oo\"\"\"""ba"r``.  
199    
200  Strings may contain newlines. Like all of Canon3,      # Canon3 <http://fenfire.org/2003/Canon3/1.0/>
201  they are encoded in Normalization Form C.      <> <http://example.org/isa> <http://example.org/document>.
202  They are enclosed in triple double quotes      <> <http://example.org/name> """Foobar
203  (see production ``literal``).      An example Canon3 "document\""""@en.
204        <> <http://example.org/name> """Foobar
205        Ein Beispiel eines Canon3-"Dokumentes\""""@de.
206        <#Foo> <http://example.org/name> """Foo fragment identifier""".
207        <http://example.org> <urn:x-foo:related> <urn:x-foo:rittlefricks>.
208        <http://example.org> <urn:x-files:rating> """7"""^^<http://www.w3.org/2001/XMLSchema#int>.
209    
210  We will register a MIME type for Canon3.  We will register a MIME type for Canon3.
211    
# Line 117  We will register a MIME type for Canon3. Line 215  We will register a MIME type for Canon3.
215  .. _Normalization Form C: http://www.unicode.org/unicode/reports/tr15/  .. _Normalization Form C: http://www.unicode.org/unicode/reports/tr15/
216  .. _NTriples: http://www.w3.org/TR/rdf-testcases/#ntriples  .. _NTriples: http://www.w3.org/TR/rdf-testcases/#ntriples
217  .. _Notation 3: http://www.w3.org/DesignIssues/Notation3.html  .. _Notation 3: http://www.w3.org/DesignIssues/Notation3.html
218    .. _RDF URI reference: http://www.w3.org/TR/rdf-concepts/#section-Graph-URIref
219    .. _language tag and data type:
220       http://www.w3.org/TR/rdf-concepts/#section-Literals

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.2

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26