Re: worries about useMentionOp and how queries relate to rules and proofs

I was a good boy and tried out the XSLT approach. Praise and cash
donations cheerfully accepted.

On Sat, Feb 05, 2005 at 12:42:59PM -0600, Pat Hayes wrote:
> >Anyhow, we do many such jobs to prepare and extract triples
> >from almost everything (even books written in PDF recently)
> >and also to consume them, to put them in SVG on pocket PC
> >etc, but for such jobs we simply use XSLT (and of course
> >Python, Java, ...)
> 
> Hmm, point taken. Well, then maybe what SPARQL should do is to 
> explicitly allow XSLT constructions as part of query, to describe 
> syntactic filters (? Does that make sense? Im a little out of my 
> depth here.)

It is feasible, but I think the practicalities make an argument for
keeping the constraint clause in the SPARQL language.

We could get rid of the constraints altogether and people could do the
same work in XSLT. For instance,

	SELECT ?annot ?author
	 WHERE { (?annot dc:creator ?author)
		 (?annot dc:created ?when) }
	   AND ( isURI(?author) ||
		 ?when < xs:dateTime(20050101T00:00:00Z) )
could be 
	SELECT ?annot ?author ?when
	 WHERE { (?annot dc:creator ?author)
		 (?annot dc:created ?when) }
+
<xsl:stylesheet version = '1.0'
     xmlns:xsl='http://www.w3.org/1999/XSL/Transform'
     xmlns:r="http://www.w3.org/2001/sw/DataAccess/rf1/result">

  <xsl:template match="r:sparql">
    <r:sparql>
      <xsl:apply-templates />
    </r:sparql>
  </xsl:template>

  <xsl:template match="r:head">
    <xsl:copy-of select='.' />
  </xsl:template>

  <xsl:template match="r:results">
    <r:results>
      <xsl:apply-templates />
    </r:results>
  </xsl:template>

  <xsl:template match="r:result[r:author/@uri 
	or translate(r:when/text(),'TZ:-','') 
	   &lt; translate('20050101T00:00:00Z','TZ:-','')]">
    <r:result>
      <xsl:apply-templates />
    </r:result>
  </xsl:template>

  <xsl:template match="r:annot">
    <xsl:copy-of select='.' />
  </xsl:template>

  <xsl:template match="r:author">
    <xsl:copy-of select='.' />
  </xsl:template>

  <xsl:template match="*" />

</xsl:stylesheet>

The constraint:
	   AND ( isURI(?author) ||
		 ?when < xs:dateTime(20050101T00:00:00Z) )
turns into:
  r:result[r:author/@uri 
	   or translate(r:when/text(),'TZ:-','') 
	      &lt; translate('20050101T00:00:00Z','TZ:-','')]">

and all the variables in the final projection (annot, author) get
enumerated. The rest of the template just keeps the result form
intact.

Benefits:
  B1. re-use tools (XSLT).
  B2. eliminate burden of SPARQL processors to do some fairly non-RDF stuff.

Drawbacks:
  D1. have to serialize as XML (no direct API calls get filtering)
  D2. only works for XML serialization of result sets (doesn't filter
      CONSTRUCT)
  D3. need to learn an extra language (and I find XSLT difficult).
-- 
-eric

office: +81.466.49.1170 W3C, Keio Research Institute at SFC,
                        Shonan Fujisawa Campus, Keio University,
                        5322 Endo, Fujisawa, Kanagawa 252-8520
                        JAPAN
        +1.617.258.5741 NE43-344, MIT, Cambridge, MA 02144 USA
cell:   +81.90.6533.3882

(eric@w3.org)
Feel free to forward this message to any list for any purpose other than
email address distribution.

Received on Saturday, 5 February 2005 19:51:04 UTC