From: Chris Hanson Date: Tue, 7 Mar 2006 06:16:26 +0000 (+0000) Subject: Export procedures to canonicalize the inputs to MAKE-RDF-TRIPLE. X-Git-Tag: 20090517-FFI~1077 X-Git-Url: https://birchwood-abbey.net/git?a=commitdiff_plain;h=207dc832298b5170996404f39a486fdd03e994e0;p=mit-scheme.git Export procedures to canonicalize the inputs to MAKE-RDF-TRIPLE. --- diff --git a/v7/src/xml/rdf-struct.scm b/v7/src/xml/rdf-struct.scm index 25c045fe1..0151e4ca7 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.4 2006/03/07 02:51:12 cph Exp $ +$Id: rdf-struct.scm,v 1.5 2006/03/07 06:16:22 cph Exp $ Copyright 2006 Massachusetts Institute of Technology @@ -37,14 +37,9 @@ USA. (define-guarantee rdf-triple "RDF triple") (define (make-rdf-triple subject predicate object) - (%make-rdf-triple (if (rdf-bnode? subject) - subject - (->absolute-uri subject 'MAKE-RDF-TRIPLE)) - (->absolute-uri predicate 'MAKE-RDF-TRIPLE) - (if (or (rdf-bnode? object) - (rdf-literal? object)) - object - (->absolute-uri object 'MAKE-RDF-TRIPLE)))) + (%make-rdf-triple (canonicalize-rdf-subject subject 'MAKE-RDF-TRIPLE) + (canonicalize-rdf-predicate predicate 'MAKE-RDF-TRIPLE) + (canonicalize-rdf-object object 'MAKE-RDF-TRIPLE))) (define-record-type (%make-rdf-bnode name) @@ -129,6 +124,21 @@ USA. (if (not (rdf-literal? o)) (add o (rdf-index-objects index)))))) +(define (canonicalize-rdf-subject subject #!optional caller) + (if (rdf-bnode? subject) + subject + (->absolute-uri subject caller))) + +(define (canonicalize-rdf-predicate predicate #!optional caller) + (->absolute-uri predicate caller)) + +(define (canonicalize-rdf-object object #!optional caller) + (cond ((or (rdf-bnode? object) + (rdf-literal? object)) + object) + ((string? object) (make-rdf-literal object #f)) + (else (->absolute-uri object caller)))) + (define match-bnode-name (let* ((name-head (char-set-union (ascii-range->char-set #x41 #x5B) diff --git a/v7/src/xml/xml.pkg b/v7/src/xml/xml.pkg index 6acb6037f..0b8662bae 100644 --- a/v7/src/xml/xml.pkg +++ b/v7/src/xml/xml.pkg @@ -1,6 +1,6 @@ #| -*-Scheme-*- -$Id: xml.pkg,v 1.66 2006/03/07 02:51:16 cph Exp $ +$Id: xml.pkg,v 1.67 2006/03/07 06:16:26 cph Exp $ Copyright 2001,2002,2003,2004,2005,2006 Massachusetts Institute of Technology @@ -530,6 +530,9 @@ USA. add-to-rdf-index + canonicalize-rdf-object + canonicalize-rdf-predicate + canonicalize-rdf-subject error:not-rdf-bnode error:not-rdf-index error:not-rdf-literal