#!/d/Bin/Python/python.exe
# -*- coding: utf-8 -*-
#
#
# $Date: 2005/04/02 07:29:46 $, by $Author: ivan $, $Revision: 1.1 $
#

from testSPARQL import ns_rdf
from testSPARQL import ns_rdfs
from testSPARQL import ns_dc
from testSPARQL import ns_foaf
from testSPARQL import ns_ns
from testSPARQL import ns_book

from rdflib import Literal
from rdfextras.sparql.operators import lt, ge
import datetime
from rdfextras.sparql.graph import GraphPattern

thresholdDate = datetime.date(2005,01,01)

rdfData ="""<?xml version="1.0" encoding="UTF-8"?>
<rdf:RDF
   xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#"
   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
   xmlns:dc="http://purl.org/dc/elements/1.1/"
   xmlns:foaf="http://xmlns.com/foaf/0.1/"
   xmlns:ns = "http://example.org/ns#"
   xmlns:book = "http://example.org/book"
>
        <rdf:Description rdf:ID="book1">
                <dc:title>SPARQL Tutorial</dc:title>
                <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">42</ns:price>
        </rdf:Description>
        <rdf:Description rdf:ID="book2">
                <dc:title>The Semantic Web</dc:title>
                <ns:price rdf:datatype="http://www.w3.org/2001/XMLSchema#integer">23</ns:price>
        </rdf:Description>
</rdf:RDF>
"""

select      = ["?title", "?price"]
pattern     = GraphPattern([("?x", ns_dc["title"],"?title")])
optional    = GraphPattern([("?x",ns_ns["price"],"?price")])
optional.addConstraint(lt("?price",30))
tripleStore = None
expected = '''
  ?title: SPARQL Tutorial
  ?price: None

  ?title: The Semantic Web
  ?price: 23
'''



