ascii version of prov-n grammar
authorLuc Moreau <l.moreau@ecs.soton.ac.uk>
Mon, 19 Nov 2012 16:28:29 +0000
changeset 4814 e309bda4a570
parent 4813 2844fe3be7b4 (current diff)
parent 4812 8bc766e31bc6 (diff)
child 4815 2b91aac2964b
ascii version of prov-n grammar
model/grammar.txt
model/grammar/Makefile
--- a/model/grammar.txt	Mon Nov 19 15:34:29 2012 +0000
+++ b/model/grammar.txt	Mon Nov 19 16:28:29 2012 +0000
@@ -1,121 +1,117 @@
-]>
-
-Productions:
 
-[1]  document                       :: "document" (namespaceDeclarations)? (expression)* (bundle)* "endDocument"
-                                 =   
-[2]  expression                     :: ( entityExpression | activityExpression | generationExpression | usageExpression
-                                 =     | startExpression | endExpression | invalidationExpression | 
-                                       communicationExpression | agentExpression | associationExpression | 
-                                       attributionExpression | delegationExpression | derivationExpression | 
-                                       influenceExpression | alternateExpression | specializationExpression | 
-                                       membershipExpression | extensibilityExpression )
-[3]  entityExpression               :: "entity" "(" identifier optionalAttributeValuePairs ")"
-                                 =   
-[4]  optionalAttributeValuePairs    :: (( "," "[" attributeValuePairs "]" ))?
-                                 =   
-[5]  attributeValuePairs            :: ( | attributeValuePair (( "," attributeValuePair ))* )
-                                 =   
-[6]  attributeValuePair             :: attribute "=" literal
-                                 =   
-[7]  activityExpression             :: "activity" "(" identifier (( "," timeOrMarker "," timeOrMarker ))? 
-                                 =     optionalAttributeValuePairs ")"
-[8]  timeOrMarker                   :: ( timeZZ | "-" )
-                                 =   
-[9]  generationExpression           :: "wasGeneratedBy" "(" optionalIdentifier eIdentifier (( "," aIdentifierOrMarker
-                                 =     "," timeOrMarker ))? optionalAttributeValuePairs ")"
-[10] optionalIdentifier             :: (( identifierOrMarker ";" ))?
-                                 =   
-[11] identifierOrMarker             :: ( identifier | "-" )
-                                 =   
-[12] usageExpression                :: "used" "(" optionalIdentifier aIdentifier (( "," eIdentifierOrMarker "," 
-                                 =     timeOrMarker ))? optionalAttributeValuePairs ")"
-[13] communicationExpression        :: "wasInformedBy" "(" optionalIdentifier aIdentifier "," aIdentifier 
-                                 =     optionalAttributeValuePairs ")"
-[14] startExpression                :: "wasStartedBy" "(" optionalIdentifier aIdentifier (( "," eIdentifierOrMarker ","
-                                 =     aIdentifierOrMarker "," timeOrMarker ))? optionalAttributeValuePairs ")"
-[15] endExpression                  :: "wasEndedBy" "(" optionalIdentifier aIdentifier (( "," eIdentifierOrMarker "," 
-                                 =     aIdentifierOrMarker "," timeOrMarker ))? optionalAttributeValuePairs ")"
-[16] invalidationExpression         :: "wasInvalidatedBy" "(" optionalIdentifier eIdentifier (( "," aIdentifierOrMarker
-                                 =     "," timeOrMarker ))? optionalAttributeValuePairs ")"
-[17] derivationExpression           :: "wasDerivedFrom" "(" optionalIdentifier eIdentifier "," eIdentifier (( "," 
-                                 =     aIdentifierOrMarker "," gIdentifierOrMarker "," uIdentifierOrMarker ))? 
-                                       optionalAttributeValuePairs ")"
-[18] agentExpression                :: "agent" "(" identifier optionalAttributeValuePairs ")"
-                                 =   
-[19] attributionExpression          :: "wasAttributedTo" "(" optionalIdentifier eIdentifier "," agIdentifier 
-                                 =     optionalAttributeValuePairs ")"
-[20] associationExpression          :: "wasAssociatedWith" "(" optionalIdentifier aIdentifier (( "," 
-                                 =     agIdentifierOrMarker "," eIdentifierOrMarker ))? optionalAttributeValuePairs ")"
-[21] delegationExpression           :: "actedOnBehalfOf" "(" optionalIdentifier agIdentifier "," agIdentifier (( "," 
-                                 =     aIdentifierOrMarker ))? optionalAttributeValuePairs ")"
-[22] influenceExpression            :: "wasInfluencedBy" "(" optionalIdentifier eIdentifier "," eIdentifier 
-                                 =     optionalAttributeValuePairs ")"
-[23] bundle                         :: "bundle" identifier (namespaceDeclarations)? (expression)* "endBundle"
-                                 =   
-[24] alternateExpression            :: "alternateOf" "(" eIdentifier "," eIdentifier ")"
-                                 =   
-[25] specializationExpression       :: "specializationOf" "(" eIdentifier "," eIdentifier ")"
-                                 =   
-[26] membershipExpression           :: "hadMember" "(" cIdentifier "," eIdentifier ")"
-                                 =   
-[27] eIdentifier                    :: identifier
-                                 =   
-[28] aIdentifier                    :: identifier
-                                 =   
-[29] agIdentifier                   :: identifier
-                                 =   
-[30] gIdentifier                    :: identifier
-                                 =   
-[31] uIdentifier                    :: identifier
-                                 =   
-[32] cIdentifier                    :: identifier
-                                 =   
-[33] eIdentifierOrMarker            :: ( eIdentifier | "-" )
-                                 =   
-[34] aIdentifierOrMarker            :: ( aIdentifier | "-" )
-                                 =   
-[35] agIdentifierOrMarker           :: ( agIdentifier | "-" )
-                                 =   
-[36] gIdentifierOrMarker            :: ( gIdentifier | "-" )
-                                 =   
-[37] uIdentifierOrMarker            :: ( uIdentifier | "-" )
-                                 =   
-[38] identifier                     :: QUALIFIED_NAME
-                                 =   
-[39] attribute                      :: QUALIFIED_NAME
-                                 =   
-[40] literal                        :: typedLiteral
-                                 =     | convenienceNotation
-[41] typedLiteral                   :: STRING_LITERAL "%%" datatype
-                                 =   
-[42] datatype                       :: QUALIFIED_NAME
-                                 =   
-[43] convenienceNotation            :: STRING_LITERAL (LANGTAG)?
-                                 =     | INT_LITERAL
+
+
+
+[1]  document                       ::= "document" (namespaceDeclarations)? (expression)* (bundle)* "endDocument"
+
+[2]  expression                     ::= ( entityExpression | activityExpression | generationExpression | usageExpression | startExpression | endExpression | invalidationExpression | communicationExpression | agentExpression | 
+  associationExpression | attributionExpression | delegationExpression | derivationExpression | influenceExpression | alternateExpression | specializationExpression | membershipExpression | 
+                                       extensibilityExpression )
+[3]  entityExpression               ::= "entity" "(" identifier optionalAttributeValuePairs ")"
+
+[4]  optionalAttributeValuePairs    ::= ( "," "[" attributeValuePairs "]" )?
+
+[5]  attributeValuePairs            ::= ( | attributeValuePair ( "," attributeValuePair )* )
+
+[6]  attributeValuePair             ::= attribute "=" literal
+
+[7]  activityExpression             ::= "activity" "(" identifier ( "," timeOrMarker "," timeOrMarker )? optionalAttributeValuePairs ")"
+
+[8]  timeOrMarker                   ::= ( time | "-" )
+
+[9]  generationExpression           ::= "wasGeneratedBy" "(" optionalIdentifier eIdentifier ( "," aIdentifierOrMarker "," timeOrMarker )? optionalAttributeValuePairs ")"
+
+[10] optionalIdentifier             ::= ( identifierOrMarker ";" )?
+
+[11] identifierOrMarker             ::= ( identifier | "-" )
+
+[12] usageExpression                ::= "used" "(" optionalIdentifier aIdentifier ( "," eIdentifierOrMarker "," timeOrMarker )? optionalAttributeValuePairs ")"
+
+[13] communicationExpression        ::= "wasInformedBy" "(" optionalIdentifier aIdentifier "," aIdentifier optionalAttributeValuePairs ")"
+
+[14] startExpression                ::= "wasStartedBy" "(" optionalIdentifier aIdentifier ( "," eIdentifierOrMarker "," aIdentifierOrMarker "," timeOrMarker )? optionalAttributeValuePairs ")"
+
+[15] endExpression                  ::= "wasEndedBy" "(" optionalIdentifier aIdentifier ( "," eIdentifierOrMarker "," aIdentifierOrMarker "," timeOrMarker )? optionalAttributeValuePairs ")"
+
+[16] invalidationExpression         ::= "wasInvalidatedBy" "(" optionalIdentifier eIdentifier ( "," aIdentifierOrMarker "," timeOrMarker )? optionalAttributeValuePairs ")"
+
+[17] derivationExpression           ::= "wasDerivedFrom" "(" optionalIdentifier eIdentifier "," eIdentifier ( "," aIdentifierOrMarker "," gIdentifierOrMarker "," uIdentifierOrMarker )? optionalAttributeValuePairs ")"
+
+[18] agentExpression                ::= "agent" "(" identifier optionalAttributeValuePairs ")"
+
+[19] attributionExpression          ::= "wasAttributedTo" "(" optionalIdentifier eIdentifier "," agIdentifier optionalAttributeValuePairs ")"
+
+[20] associationExpression          ::= "wasAssociatedWith" "(" optionalIdentifier aIdentifier ( "," agIdentifierOrMarker "," eIdentifierOrMarker )? optionalAttributeValuePairs ")"
+
+[21] delegationExpression           ::= "actedOnBehalfOf" "(" optionalIdentifier agIdentifier "," agIdentifier ( "," aIdentifierOrMarker )? optionalAttributeValuePairs ")"
+
+[22] influenceExpression            ::= "wasInfluencedBy" "(" optionalIdentifier eIdentifier "," eIdentifier optionalAttributeValuePairs ")"
+
+[23] bundle                         ::= "bundle" identifier (namespaceDeclarations)? (expression)* "endBundle"
+
+[24] alternateExpression            ::= "alternateOf" "(" eIdentifier "," eIdentifier ")"
+
+[25] specializationExpression       ::= "specializationOf" "(" eIdentifier "," eIdentifier ")"
+
+[26] membershipExpression           ::= "hadMember" "(" cIdentifier "," eIdentifier ")"
+
+[27] eIdentifier                    ::= identifier
+
+[28] aIdentifier                    ::= identifier
+
+[29] agIdentifier                   ::= identifier
+
+[30] gIdentifier                    ::= identifier
+
+[31] uIdentifier                    ::= identifier
+
+[32] cIdentifier                    ::= identifier
+
+[33] eIdentifierOrMarker            ::= ( eIdentifier | "-" )
+
+[34] aIdentifierOrMarker            ::= ( aIdentifier | "-" )
+
+[35] agIdentifierOrMarker           ::= ( agIdentifier | "-" )
+
+[36] gIdentifierOrMarker            ::= ( gIdentifier | "-" )
+
+[37] uIdentifierOrMarker            ::= ( uIdentifier | "-" )
+
+[38] identifier                     ::= QUALIFIED_NAME
+
+[39] attribute                      ::= QUALIFIED_NAME
+
+[40] literal                        ::= typedLiteral
+  | convenienceNotation
+[41] typedLiteral                   ::= STRING_LITERAL "%%" datatype
+
+[42] datatype                       ::= QUALIFIED_NAME
+
+[43] convenienceNotation            ::= STRING_LITERAL (LANGTAG)?
+  | INT_LITERAL
                                        | QUALIFIED_NAME_LITERAL
-[44] timeZZ                         :: DATETIME
-                                 =   
-[45] namespaceDeclarations          :: ( defaultNamespaceDeclaration | namespaceDeclaration ) (namespaceDeclaration)*
-                                 =   
-[46] namespaceDeclaration           :: "prefix" PN_PREFIX namespace
-                                 =   
-[47] defaultNamespaceDeclaration    :: "default" IRI_REF
-                                 =   
-[48] namespace                      :: IRI_REF
-                                 =   
-[49] extensibilityExpression        :: QUALIFIED_NAME "(" optionalIdentifier extensibilityArgument (( "," 
-                                 =     extensibilityArgument ))* optionalAttributeValuePairs ")"
-[50] extensibilityArgument          :: ( identifierOrMarker | literal | timeZZ | extensibilityExpression | 
-                                 =     extensibilityTuple )
-[51] extensibilityTuple             :: "{" extensibilityArgument (( "," extensibilityArgument ))* "}"
-                                 =     | "(" extensibilityArgument (( "," extensibilityArgument ))* ")"
-[52] <QUALIFIED_NAME>               :: (( PN_PREFIX ":" ))? PN_LOCAL
-                                 =     | PN_PREFIX ":"
-[53] <PN_LOCAL>                     :: ( PN_CHARS_U | [0-9] | PN_CHARS_OTHERS ) (( (( PN_CHARS | "." | PN_CHARS_OTHERS
-                                 =     ))* ( PN_CHARS | PN_CHARS_OTHERS ) ))?
-[54] <PN_CHARS_OTHERS>              :: "/"
-                                 =     | "@"
+[44] time                         ::= DATETIME
+
+[45] namespaceDeclarations          ::= ( defaultNamespaceDeclaration | namespaceDeclaration ) (namespaceDeclaration)*
+
+[46] namespaceDeclaration           ::= "prefix" PN_PREFIX namespace
+
+[47] defaultNamespaceDeclaration    ::= "default" IRI_REF
+
+[48] namespace                      ::= IRI_REF
+
+[49] extensibilityExpression        ::= QUALIFIED_NAME "(" optionalIdentifier extensibilityArgument ( "," extensibilityArgument )* optionalAttributeValuePairs ")"
+
+[50] extensibilityArgument          ::= ( identifierOrMarker | literal | time | extensibilityExpression | extensibilityTuple )
+
+[51] extensibilityTuple             ::= "{" extensibilityArgument ( "," extensibilityArgument )* "}"
+  | "(" extensibilityArgument ( "," extensibilityArgument )* ")"
+[52] <QUALIFIED_NAME>               ::= ( PN_PREFIX ":" )? PN_LOCAL
+  | PN_PREFIX ":"
+[53] <PN_LOCAL>                     ::= ( PN_CHARS_U | [0-9] | PN_CHARS_OTHERS ) ( (( PN_CHARS | "." | PN_CHARS_OTHERS )* ( PN_CHARS | PN_CHARS_OTHERS ) ))?
+
+[54] <PN_CHARS_OTHERS>              ::= "/"
+  | "@"
                                        | "~"
                                        | "&"
                                        | "+"
@@ -126,25 +122,24 @@
                                        | "!"
                                        | PERCENT
                                        | PN_CHARS_ESC
-[55] <PN_CHARS_ESC>                 :: "\\" ( "=" | "'" | "(" | ")" | "," | "-" | ":" | ";" | "[" | "]" | "." )
-                                 =   
-[56] <PERCENT>                      :: "%" HEX HEX
-                                 =   
-[57] <HEX>                          :: [0-9]
-                                 =     | [A-F]
+[55] <PN_CHARS_ESC>                 ::= "\\" ( "=" | "'" | "(" | ")" | "," | "-" | ":" | ";" | "[" | "]" | "." )
+
+[56] <PERCENT>                      ::= "%" HEX HEX
+
+[57] <HEX>                          ::= [0-9]
+  | [A-F]
                                        | [a-f]
-[58] <STRING_LITERAL>               :: STRING_LITERAL2
-                                 =     | STRING_LITERAL_LONG2
-[59] <PREFX>                        :: PN_PREFIX
-                                 =   
-[60] <INT_LITERAL>                  :: ("-")? (DIGIT)+
-                                 =   
-[61] <QUALIFIED_NAME_LITERAL>       :: "'" QUALIFIED_NAME "'"
-                                 =   
-[62] <DIGIT>                        :: [0-9]
-                                 =   
-[63] <DATETIME>                     :: DIGIT DIGIT DIGIT DIGIT "-" DIGIT DIGIT "-" DIGIT DIGIT "T" DIGIT DIGIT ":" 
-                                 =     DIGIT DIGIT ":" DIGIT DIGIT (( "." DIGIT (( DIGIT (DIGIT)? ))? ))? (( "Z" | 
-                                       TIMEZONEOFFSET ))?
-[64] <TIMEZONEOFFSET>               :: ( "+" | "-" ) DIGIT DIGIT ":" DIGIT DIGIT
-                                 =   
+[58] <STRING_LITERAL>               ::= STRING_LITERAL2
+  | STRING_LITERAL_LONG2
+[59] <PREFX>                        ::= PN_PREFIX
+
+[60] <INT_LITERAL>                  ::= ("-")? (DIGIT)+
+
+[61] <QUALIFIED_NAME_LITERAL>       ::= "'" QUALIFIED_NAME "'"
+
+[62] <DIGIT>                        ::= [0-9]
+
+[63] <DATETIME>                     ::= DIGIT DIGIT DIGIT DIGIT "-" DIGIT DIGIT "-" DIGIT DIGIT "T" DIGIT DIGIT ":" DIGIT DIGIT ":" DIGIT DIGIT ( "." DIGIT (( DIGIT (DIGIT)? )? ))? (( "Z" | TIMEZONEOFFSET ))?
+
+[64] <TIMEZONEOFFSET>               ::= ( "+" | "-" ) DIGIT DIGIT ":" DIGIT DIGIT
+
--- a/model/grammar/Makefile	Mon Nov 19 15:34:29 2012 +0000
+++ b/model/grammar/Makefile	Mon Nov 19 16:28:29 2012 +0000
@@ -33,8 +33,11 @@
 IN2.HTML=tmp/ll2.html
 
 do.ll.txt:
-	w3m -dump -cols 120 ll.html > ll.txt
-	sed -n '/65/q;p' ll.txt > ../grammar.txt
+	w3m -dump -cols 240 ll.html > ll.txt
+	$(MAKE) grammar.cleanup
+
+grammar.cleanup:
+	sed -n '/65/q;p' ll.txt | sed -e "s/::/::=/"  | sed -e "s/                                 =   //" | sed -e "s/]>//" | sed -e "s/Productions://" | sed -e "s/((/(/"  | sed -e "s/))/)/"  | sed -e "s/timeZZ/time/" > ../grammar.txt
 
 
 
--- a/xml/prov-xml.html	Mon Nov 19 15:34:29 2012 +0000
+++ b/xml/prov-xml.html	Mon Nov 19 16:28:29 2012 +0000
@@ -256,6 +256,76 @@
 
 </section> <!-- end introduction -->
 
+<section id="schema-design">
+<h2>XML Schema Design</h2>
+
+<p>Several general design principles and patterns were used in the
+construction of the PROV XML Schema.
+</p>
+
+<h3><i>Salami Slice</i> Design Pattern</h3>
+
+<p>The general design pattern for the XML schema has been
+called <i>Salami Slice Design</i> (cite?).  With this design, the
+individual components are each defined at the top level as separate
+elements with distinct types.  This allows the types to be easily
+reusable for domain specific extensions.
+</p>
+
+<h3>Elements vs. Attributes</h3>
+
+<p>The general PROV-N syntax patterns for expressing provenance
+concepts are:
+</p>
+
+<pre class="codeexample">
+thing(id, elem1, elem2, ..., [attr1=val1, attr2=val2])
+concept(id; elem1, elem2, ... [attr1=val2, attr2=val2])
+</pre>
+
+<p>In both cases (required id or optional id), the PROV-N id is
+treated as an XML attribute, the PROV-N "elements" are treated as XML
+elements, always with the same required order (position) as the
+PROV-DM/PROV-N description, and optional PROV-N "attributes", if
+allowed, always follow and are also represented by XML elements.  As
+in PROV-N, the attributes can be specified multiple times, and in any
+order, as long as they are all at the end of the encompassing element.
+</p>
+
+<p>Wherever an "id" is referenced from a later concept, the id is
+referenced as a prov:ref attribute of the element within the concept.
+</p>
+
+<p>This transformation technique yields a general XML pattern:
+</p>
+
+<pre class="codeexample">
+&lt;prov:thing prov:id="id"&gt;
+  &lt;prov:elem1 /&gt;
+  &lt;prov:elem2 /&gt;
+  ...
+  &lt;prov:attr1&gt;val1&lt;/prov:attr1&gt;
+  &lt;prov:attr2&gt;val2&lt;/prov:attr2&gt;
+  ...
+&lt;/prov:thing&gt;
+</pre>
+
+<p>Most of the concepts described below follow this general pattern.
+</p>
+
+<div class="note">
+<p>REVIEW QUESTION:</p>
+<p>Is this ordering of elements/attributes reasonable/satisfactory?</p>
+<p>Would it be better to loosen the ordering requirement allowing any mix
+of elements/attributes, or to tighten the ordering requirement,
+requiring all "prov:" namespace attributes to precede all non-"prov:"
+namespace attributes when expressed as XML elements?
+</p>
+</div>
+
+
+</section>
+
 <!-- should we instead break the schema down into complex types and elements? -->
 <section id="schema-components">