From 4e3db7fefd9fe058fdf759d5c41cce6c286a7d4d Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 13 Aug 2007 17:17:47 +0000 Subject: [PATCH] Add predicates and guarantees to validate components of a triple. --- v7/src/xml/rdf-struct.scm | 20 +++++++++++++++++++- v7/src/xml/xml.pkg | 11 ++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/v7/src/xml/rdf-struct.scm b/v7/src/xml/rdf-struct.scm index bb221d946..39f78e7b8 100644 --- a/v7/src/xml/rdf-struct.scm +++ b/v7/src/xml/rdf-struct.scm @@ -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)) diff --git a/v7/src/xml/xml.pkg b/v7/src/xml/xml.pkg index 96755aeef..8cd300347 100644 --- a/v7/src/xml/xml.pkg +++ b/v7/src/xml/xml.pkg @@ -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 -- 2.25.1