Add predicates and guarantees to validate components of a triple.
authorChris Hanson <org/chris-hanson/cph>
Mon, 13 Aug 2007 17:17:47 +0000 (17:17 +0000)
committerChris Hanson <org/chris-hanson/cph>
Mon, 13 Aug 2007 17:17:47 +0000 (17:17 +0000)
v7/src/xml/rdf-struct.scm
v7/src/xml/xml.pkg

index bb221d946b41a8c752b1884c7ab671910337dcb7..39f78e7b8a12e9c1216fe8334fd768c6d16e65ca 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: rdf-struct.scm,v 1.31 2007/08/10 19:26:02 cph Exp $
+$Id: rdf-struct.scm,v 1.32 2007/08/13 17:17:45 cph Exp $
 
 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
@@ -69,6 +69,24 @@ USA.
 (define rdf-triples (make-equal-hash-table))
 (define event:new-rdf-triple (make-event-distributor))
 
+(define (rdf-subject? thing)
+  (or (absolute-uri? thing)
+      (rdf-bnode? thing)
+      (rdf-graph? thing)))
+
+(define (rdf-predicate? thing)
+  (absolute-uri? thing))
+
+(define (rdf-object? thing)
+  (or (absolute-uri? thing)
+      (rdf-bnode? thing)
+      (rdf-graph? thing)
+      (rdf-literal? thing)))
+
+(define-guarantee rdf-subject "RDF subject")
+(define-guarantee rdf-predicate "RDF predicate")
+(define-guarantee rdf-object "RDF object")
+
 (define (canonicalize-rdf-subject subject #!optional caller)
   (cond ((or (rdf-bnode? subject) (rdf-graph? subject)) subject)
        ((%decode-bnode-uri subject))
index 96755aeefe70bb2fea3dd6c0781a15a11f93e115..8cd3003472d83e4643277219a058caad64136c8e 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: xml.pkg,v 1.97 2007/08/10 19:26:03 cph Exp $
+$Id: xml.pkg,v 1.98 2007/08/13 17:17:47 cph Exp $
 
 Copyright (C) 1986, 1987, 1988, 1989, 1990, 1991, 1992, 1993, 1994,
     1995, 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005,
@@ -548,9 +548,12 @@ USA.
          error:not-rdf-bnode
          error:not-rdf-graph
          error:not-rdf-literal
+         error:not-rdf-object
+         error:not-rdf-predicate
          error:not-rdf-prefix
          error:not-rdf-prefix-registry
          error:not-rdf-qname
+         error:not-rdf-subject
          error:not-rdf-triple
          event:new-rdf-graph
          event:new-rdf-triple
@@ -558,9 +561,12 @@ USA.
          guarantee-rdf-bnode
          guarantee-rdf-graph
          guarantee-rdf-literal
+         guarantee-rdf-object
+         guarantee-rdf-predicate
          guarantee-rdf-prefix
          guarantee-rdf-prefix-registry
          guarantee-rdf-qname
+         guarantee-rdf-subject
          guarantee-rdf-triple
          make-rdf-bnode
          make-rdf-graph
@@ -579,6 +585,8 @@ USA.
          rdf-literal-text
          rdf-literal-type
          rdf-literal?
+         rdf-object?
+         rdf-predicate?
          rdf-prefix-expansion
          rdf-prefix-registry->alist
          rdf-prefix-registry?
@@ -587,6 +595,7 @@ USA.
          rdf-qname-local
          rdf-qname-prefix
          rdf-qname?
+         rdf-subject?
          rdf-triple-object
          rdf-triple-predicate
          rdf-triple-subject