W3C home > Mailing lists > Public > public-rif-wg@w3.org > August 2007

rif xml syntax (again)

From: Sandro Hawke <sandro@w3.org>
Date: Fri, 24 Aug 2007 14:19:54 -0400
To: public-rif-wg@w3.org
Message-ID: <2173.1187979594@ubuhebe>


I'm working on a more concrete RIF XML Syntax proposal, trying to nail
down the various issues that have been floating around.  Here's a run
through of the issues, each with a proposed solution, and finally an
example of a simple ruleset using this syntax.  

I do not yet have an XML schema for this, which I know I'm supposed to
produce, and I don't have software to translate between this and any
other formats yet -- I just doing it by hand at the moment.  I expect to
do more on this before Tuesday, but I wanted to get at least this out
now.

      -- Sandro

================================================================


ISSUE 1.  Leaf Class == Visible Class

See thread starting with
   http://lists.w3.org/Archives/Public/public-rif-wg/2007Jul/0055

PROPOSED/USED: visibility of syntactic classes is determined and indicated 
          solely by their place in the syntactic class hierarchy 
          (ie change "TERM" to "Term", etc.)

(otherwise classes can't be visible in some dialects and invisible in
others.)

================

ISSUE 2.  Const vs Literal

See thread starting around
   http://lists.w3.org/Archives/Public/public-rif-wg/2007Jul/0081.html

PROPOSED/USED: change the abstract syntax for Term to be this:


    class Term
    
        subclass Var
            property name: xs:string
    
        subclass Constant

            subclass Literal

                 subclass TypedLiteral     # for example:   3.1
                     property datatype: xs:anyURI
                     property lexicalRepresentation: xs:string

                 subclass PlainLiteral     # for example:   "Hello"
                     property content: xs:string
                     property language: xs:string?

            subclass NamedConstant

                subclass GlobalConstant    # for example:   http://eg.org#p
                     property name: xs:anyURI
    
                subclass LocalConstant     # for example:  p
                     property name: xs:string
        
        subclass Uniterm       
            property op: Const
            property arg: list of TERM

NOTE that some of this structure is not visible in the RIF XML syntax.
For example, a PlainLiteral value is serialized by just including the
text value -- the property name "content" is not used.

================
    
ISSUE 3.  xsi:type vs rdf:datatype

There are two different conventions for indicating the datatype of a
literal data value occuring in an instance document.  Unfortunately,
they do not appear to be compatible; there appears to be no way to
specify xsi:type in RDF/XML.

Note that the SPARQL results format (which is not RDF/XML) used
xsi:type in one version and then took it out.  See
http://www.w3.org/TR/2005/WD-rdf-sparql-XMLres-20050801/#changes
I don't know the full story there.

PROPOSED/USED: Use rdf:datatype instead of xsi:type

================

ISSUE 4.  rdf:RDF vs rif:Document document-level wrapper

rdf:RDF isn't necessary for RDF/XML, but some apps (like RDF
Validator) seem to require it anyway.    It helps make it clear that
this is intended to be parseable as RDF.

PROPOSED/USED: use rdf:RDF wrapper

================

ISSUE 5.  Literal data values in lists

Unfortunately, RDF/XML parsetype="Collection" does not allow literal
data values.  (very, very annoying.)  So how do you write a condition
like p(5)?

Here are the options I see (written in Turtle, to make it clear what
triples are actually being conveyed in the RDF/XML).

 OPTION 1

    Define a non-standard dialect of RDF/XML, "RDF/XML with the li
    patch", which allows "rdf:li" to be used to put literals into
    lists.

    [ a rif:Uniterm;
      rif:op [ a rif:LocalConstant; rif:name "p" ];
      rif:arg ( "5"^^xs:int )
    ]

 OPTION 2

    Use a bnode which is owl:sameAs the desired value.

    [ a rif:Uniterm;
      rif:op [ a rif:LocalConstant; rif:name "p" ];
      rif:arg ( 
          [ owl:sameAs "5"^^xs:int ]
      )         
   ]

 OPTION 3

    Use a bnode which is has a rif:value of the desired value.

    [ a rif:Uniterm;
      rif:op [ a rif:LocalConstant; rif:name "p" ];
      rif:arg ( 
          [ rif:value "5"^^xs:int ]
      )
   ]

 OPTION 4

    Use a bnode which is has a rdf:value of the desired value.

    [ a rif:Uniterm;
      rif:op [ a rif:LocalConstant; rif:name "p" ];
      rif:arg ( 
          [ rdf:value "5"^^xs:int ]
      )
   ]

 OPTION 5

    Don't try to use RDF datatypes -- just fully serialize our
    abstract syntax.

    [ a rif:Uniterm;
      rif:op [ a rif:LocalConstant; rif:name "p" ];
      rif:arg ( 
          [ a rif:TypedLiteral;
            rif:datatype "http://www.w3.org/2001/XMLSchema#int";
            rif:lexicalRepresentation "5" ]
      )
   ]

 OPTION 6 

   Don't use parsetype Collection -- just use first/rest

 OPTION 7

   Don't use rdf:Lists at all -- use rdf:Seq.

   Concerns -- rdf:Seq support is weak.  Can the values be constrained
   using OWL?  It's not closed -- you don't know if you have a partial
   graph.   Would that ever matter....?

 OPTION 8

   Don't try to use RDF/XML   :-)


PROPOSED/USED: OPTION 4 (rdf:value)     [but I don't like any of the options]

================

ISSUE 6.  Use multivalues instead of lists where order has no meaning

The current abstract syntax says things like:

  class Ruleset
     property formula : list of Rule

although the order of rules in a ruleset has no semantics in BLD.  

PROPOSED/USED: have an unordered collection mechanism in ASN07, written
          using the Kleene operators (*,+,?), and using them for such
          cases, like this: 

  class Ruleset
     property formula : Rule*

  class Forall
     property declare: Var*
     property formula: Clause

================

ISSUE 7.  Allow structure sharing, so that instead of 

         ...
	    <op>
	      <GlobalConstant>
		<name>http://example.com/app#p</name>
	      </GlobalConstant>
	    </op>
         ...

repeated wherever we need app:p, we say:

         ...
	    <op>
	      <GlobalConstant rdf:nodeId="p">
		<name>http://example.com/app#p</name>
	      </GlobalConstant>
	    </op>
         ...

the first time, and 

	    <op rdf:nodeId="p" />

each later time.

PROPOSED/USED:  Allow syntactic structure sharing.


================================================================

<!--   

ruleset7:   app:p(1).
            app:q(1).
            all X app:p(X) & app:q(X) -> app:r(X).

Parses to 55 triples.
(That's about one triple per character of the above informal 
presentation syntax.  :-)

-->


<!DOCTYPE rdf:RDF [
 <!ENTITY xsd     "http://www.w3.org/2001/XMLSchema-datatypes#">
]>
<rdf:RDF xmlns="http://www.w3.org/2007/rif#"
	 xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
	 xmlns:rif="http://www.w3.org/2007/rif#"
	 xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
	 xmlns:xsd="&xsd;"
	 >
  <Ruleset>

    <!--  app:p(1).  -->
    <formula>
      <Forall>
	<formula>
	  <Uniterm>
	    <op>
	      <GlobalConstant rdf:nodeID="p">
		<name>http://example.com/app#p</name>
	      </GlobalConstant>
	    </op>
	    <arg rdf:parseType="Collection">
                <rdf:Description>
		  <value rdf:datatype="&xsd;integer">1</value>
		</rdf:Description>
	    </arg>
	  </Uniterm>
	</formula>
      </Forall>
    </formula>

    <formula>
      <!--  app:q(1).  -->
      <Forall>
	<formula>
	  <Uniterm>
	    <op>
	      <GlobalConstant rdf:nodeID="q">
		<name>http://example.com/app#q</name>
	      </GlobalConstant>
	    </op>
	    <arg rdf:parseType="Collection">
                <rdf:Description>
		  <value rdf:datatype="&xsd;integer">1</value>
		</rdf:Description>
	    </arg>
	  </Uniterm>
	</formula>
      </Forall>
    </formula>

    <!--  forall X app:p(X) & app:q(X) -> app:r(1).  -->
    <formula>
      <Forall>
	<declare>
	  <Var rdf:nodeID="X">
	    <name>X</name>
	  </Var>
	</declare>
	<formula>
	  <Implies>
	    <if>
	      <And>
		<formula rdf:parseType="Collection">

		  <!-- app:p(X) -->
		  <Uniterm>
		    <op rdf:nodeID="p" />
		    <arg rdf:parseType="Collection">
		      <rdf:Description rdf:nodeID="X" />
		    </arg>
		  </Uniterm>

		  <!-- app:q(X) -->
		  <Uniterm>
		    <op rdf:nodeID="q" />
		    <arg rdf:parseType="Collection">
		      <rdf:Description rdf:nodeID="X" />
		    </arg>
		  </Uniterm>
		  
		</formula>
	      </And>
	    </if>
	    <then>

	      <!-- app:r(X) -->
	      <Uniterm>
		<op>
		  <GlobalConstant>
		    <name>http://example.com/app#r</name>
		  </GlobalConstant>
		</op>
		<arg rdf:parseType="Collection">
		  <rdf:Description rdf:nodeID="X" />
		</arg>
	      </Uniterm>

	    </then>
	  </Implies>
	</formula>
      </Forall>
    </formula>

  </Ruleset>
</rdf:RDF>
Received on Friday, 24 August 2007 18:22:20 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Tuesday, 2 June 2009 18:33:40 GMT