#| -*-Scheme-*-
-$Id: xml-parser.scm,v 1.40 2003/09/16 04:32:59 cph Exp $
+$Id: xml-parser.scm,v 1.41 2003/09/24 03:26:19 cph Exp $
Copyright 2001,2002,2003 Massachusetts Institute of Technology
(alt (sbracket description "\"" "\"" (match (* (alphabet a1))))
(sbracket description "'" "'" (match (* (alphabet a2))))))))
-(define (simple-attribute-value? v)
- (and (pair? v)
- (string? (car v))
- (null? (cdr v))))
-
(define (read-xml-file pathname #!optional pi-handlers)
(call-with-input-file pathname
(lambda (port)
(define (transform-declaration attributes text-decl? p)
(if (not (for-all? attributes
(lambda (attribute)
- (simple-attribute-value? (cdr attribute)))))
+ (simple-xml-attribute-value? (cdr attribute)))))
(perror p "XML declaration can't contain entity refs" attributes))
(let ((finish
(lambda (version encoding standalone)
"Incorrect attribute value"
(string->symbol name)))
(if (and (not (eq? type '|CDATA|))
- (simple-attribute-value? av))
+ (simple-xml-attribute-value? av))
(set-car! av (trim-attribute-whitespace (car av))))
attributes)
(begin
(pn (cdr name)))
(let ((uri
(lambda ()
- (if (not (simple-attribute-value? value))
+ (if (not (simple-xml-attribute-value? value))
(perror pn "Illegal namespace URI" value))
(if (string-null? (car value))
#f ;xmlns=""
(let ((entity (find-parameter-entity name)))
(and entity
(xml-parameter-!entity-value entity))))))
- (if (simple-attribute-value? value)
+ (if (simple-xml-attribute-value? value)
(car value)
(begin
(set! *parameter-entities* 'STOP)
(let ((value (xml-!entity-value entity)))
(cond ((xml-external-id? value) #f)
(in-attribute? value)
- ((simple-attribute-value? value)
+ ((simple-xml-attribute-value? value)
(reparse-entity-value-string name (car value) p))
(else
(if (or *standalone?* *internal-dtd?*)
(list name type
(if (and (not (eq? type '|CDATA|))
(pair? default)
- (simple-attribute-value? (cdr default)))
+ (simple-xml-attribute-value? (cdr default)))
(list (car default)
(trim-attribute-whitespace (cadr default)))
default))))
#| -*-Scheme-*-
-$Id: xml-struct.scm,v 1.24 2003/09/17 03:20:45 cph Exp $
+$Id: xml-struct.scm,v 1.25 2003/09/24 03:26:23 cph Exp $
Copyright 2001,2002,2003 Massachusetts Institute of Technology
((combo-name? name) (combo-name-simple name))
(else (error:not-xml-name name 'XML-NAME-simple))))
+(define (xml-name-simple=? name simple)
+ (eq? (xml-name-simple name) simple))
+
(define (xml-name-string name)
(symbol-name (xml-name-simple name)))
((combo-name? name) (universal-name-uri (combo-name-universal name)))
(else (error:not-xml-name name 'XML-NAME-URI))))
+(define (xml-name-uri=? name uri)
+ (eq? (xml-name-uri name) uri))
+
(define (xml-name-prefix name)
(let ((simple
(lambda (name)
((combo-name? name) (simple (combo-name-simple name)))
(else (error:not-xml-name name 'XML-NAME-PREFIX)))))
+(define (xml-name-prefix=? name prefix)
+ (eq? (xml-name-prefix name) prefix))
+
(define (xml-name-local name)
(cond ((xml-nmtoken? name)
(let ((s (symbol-name name)))
((combo-name? name) (universal-name-local (combo-name-universal name)))
(else (error:not-xml-name name 'XML-NAME-LOCAL))))
+(define (xml-name-local=? name local)
+ (eq? (xml-name-local name) local))
+
(define (xml-name=? n1 n2)
(let ((lose (lambda (n) (error:not-xml-name n 'XML-NAME=?))))
(cond ((xml-nmtoken? n1)
(and (pair? object)
(list-of-type? object xml-attribute-value-item?)))
+(define (simple-xml-attribute-value? object)
+ (and (pair? object)
+ (xml-char-data? (car object))
+ (null? (cdr object))))
+
(define (xml-attribute-value-item? object)
(or (xml-char-data? object)
(xml-entity-ref? object)))
#| -*-Scheme-*-
-$Id: xml.pkg,v 1.25 2003/09/17 03:20:41 cph Exp $
+$Id: xml.pkg,v 1.26 2003/09/24 03:26:16 cph Exp $
Copyright 2001,2002,2003 Massachusetts Institute of Technology
set-xml-unparsed-!entity-id!
set-xml-unparsed-!entity-name!
set-xml-unparsed-!entity-notation!
+ simple-xml-attribute-value?
xml-!attlist-definitions
xml-!attlist-name
xml-!attlist?
xml-intern
xml-name-hash
xml-name-local
+ xml-name-local=?
xml-name-prefix
+ xml-name-prefix=?
xml-name-simple
+ xml-name-simple=?
xml-name-string
xml-name-uri
+ xml-name-uri=?
xml-name=?
xml-name?
xml-nmtoken?
read-xml-file
string->xml
substring->xml)
- (export (runtime xml structure)
+ (export (runtime xml)
alphabet:name-initial
alphabet:name-subsequent))