W3C home > Mailing lists > Public > public-rdf-dawg@w3.org > January to March 2005

Re: about OPTIONAL blocks

From: Seaborne, Andy <andy.seaborne@hp.com>
Date: Wed, 26 Jan 2005 14:30:16 +0000
Message-ID: <41F7A978.5000501@hp.com>
To: Alberto Reggiori <alberto@asemantics.com>
CC: RDF Data Access Working Group <public-rdf-dawg@w3.org>

Alberto Reggiori wrote:
> 
> in the current editor's draft v1.174 specified grammar the OPTIONAL 
> keyword is also allowed in front of an optional block specified by [] 
> (square brackets) and well as a constraints expression:
> 
> [7]     OptionalGraphPattern   ::=   'optional' PatternElement | '[' 
> GraphPattern ']'
> [8]     GraphPattern                  ::=   GraphAndPattern ('union' 
> GraphAndPattern)*
> [9]     GraphAndPattern           ::=   PatternElement+
> [10]   PatternElement              ::=   TriplePattern | 
> GroupGraphPattern | SourceGraphPattern | OptionalGraphPattern | 'and'? 
> Expression
> 
> making legal queries like:
> 
> PREFIX foaf: <http://xmlns.com/foaf/0.1/>
> SELECT ?name ?mbox
> WHERE  ( ?x foaf:name  ?name )
>         OPTIONAL [ ( ?x  foaf:mbox  ?mbox ) ]
> OPTIONAL
> 	AND ( ?x =~ /foo/ )
> 
> which is clearly redundancy for the the second triple-pattern, and 
> wrong(?) for the constraints clause.

By allowing query patterns to be built from smaller graph patterns, it is 
possible to write things in poor style (that is, by almost anyone's judgement). 
  Mechanically produced queries do this - no style! - and in that case the 
regualr composition is very helpful.

The "OPTIONAL []" is merely a reflection that

  [
    [
      ( ?x  foaf:mbox  ?mbox )
    ]
  ]

(extreme layout just to be clear)

is legal.


> 
> what about getting rid of the OPTIONAL keyword and only allow clearly 
> marked optional blocks?

If we remove one, I much prefer to remove [] because 1/ we have a keyword based 
language and 2/ [] can be better used for marking the outside of constraints. 
And of course [] is bNodes in some languages.

> 
> I would prefer to have optional blocks (or one/more triple-patterns 
> and/or constraints) expressed using [] (square brackets) - which would 
> reduce the above [7] production to:
> 
> [7]     OptionalGraphPattern   ::=   '[' GraphPattern ']'
> 
> or if you wish to OPTIONAL just a triple-pattern, not sure the simply 
> s/PatternElement/TriplePattern/ in [7] would make the trick - which 
> might make the grammar ambiguous.
> 
> did this issue come up already in the recent grammar discussions or 
> people implementing OPTIONALs?

We hope to have the grammar reflecting the face-to-face "real soon now".

	Andy

> 
> Yours
> 
> Alberto
> 
> -
> Alberto Reggiori, Senior Partner, R&D @Semantics S.R.L.
> www.asemantics.com Milan Office
> 
Received on Wednesday, 26 January 2005 14:31:00 GMT

This archive was generated by hypermail 2.3.1 : Tuesday, 26 March 2013 16:15:22 GMT