Don't discard XML comments; these are important to preserve when
authorChris Hanson <org/chris-hanson/cph>
Sat, 7 Dec 2002 04:14:19 +0000 (04:14 +0000)
committerChris Hanson <org/chris-hanson/cph>
Sat, 7 Dec 2002 04:14:19 +0000 (04:14 +0000)
processing documents.

v7/src/xml/load.scm
v7/src/xml/xml-output.scm
v7/src/xml/xml-parser.scm
v7/src/xml/xml-struct.scm
v7/src/xml/xml.pkg

index 6407aabc6852d3e854c255e477402c07f5cd472d..cecb146317280aefe1fbb91722b9299417c279b8 100644 (file)
@@ -1,6 +1,6 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: load.scm,v 1.6 2002/11/20 19:46:27 cph Exp $
+;;; $Id: load.scm,v 1.7 2002/12/07 04:13:39 cph Exp $
 ;;;
 ;;; Copyright (c) 2001, 2002 Massachusetts Institute of Technology
 ;;;
@@ -26,4 +26,4 @@
 (with-working-directory-pathname (directory-pathname (current-load-pathname))
   (lambda ()
     (package/system-loader "xml" '() 'QUERY)))
-(add-subsystem-identification! "XML" '(0 2))
\ No newline at end of file
+(add-subsystem-identification! "XML" '(0 3))
\ No newline at end of file
index 8b63d52b5cc126a7cf318882246e3df0d229f2d4..d6934fc461ee94581b94de674da7e48348a9b643 100644 (file)
@@ -1,8 +1,8 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: xml-output.scm,v 1.2 2002/11/20 19:46:27 cph Exp $
+;;; $Id: xml-output.scm,v 1.3 2002/12/07 04:13:58 cph Exp $
 ;;;
-;;; Copyright (c) 2001 Massachusetts Institute of Technology
+;;; Copyright (c) 2001, 2002 Massachusetts Institute of Technology
 ;;;
 ;;; This file is part of MIT Scheme.
 ;;;
          (write-string "</" port)
          (write-xml-name (xml-element-name element) port)
          (write-string ">" port))
-       (write-string "/>" port))))
+       (write-string " />" port))))
+
+(define-method write-xml ((pi xml-comment-rtd) port)
+  (write-string "<!--" port)
+  (write-string (xml-comment-text pi) port)
+  (write-string "-->" port))
 
 (define-method write-xml ((pi xml-processing-instructions-rtd) port)
   (write-string "<?" port)
index b0672fdb8fee799d31f8355279a72e72326ad4b7..0f7f6067dbe6d9f3ff7d24e3a86cb4e9fd2a5f5a 100644 (file)
@@ -1,8 +1,8 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: xml-parser.scm,v 1.12 2002/11/20 19:46:27 cph Exp $
+;;; $Id: xml-parser.scm,v 1.13 2002/12/07 04:14:09 cph Exp $
 ;;;
-;;; Copyright (c) 2001 Massachusetts Institute of Technology
+;;; Copyright (c) 2001, 2002 Massachusetts Institute of Technology
 ;;;
 ;;; This file is part of MIT Scheme.
 ;;;
   (terminated-region-parser "character data" alphabet:char-data "]]>"))
 
 (define parse-comment                  ;[15]
-  (let ((match-body
-        (terminated-region-matcher "comment" alphabet:xml-char "--")))
+  (let ((parse-body
+        (terminated-region-parser "comment" alphabet:xml-char "--")))
     (*parser
-     (sbracket "comment" "<!--" "-->"
-       (noise match-body)))))
+     (encapsulate
+        (lambda (v)
+          (make-xml-comment (vector-ref v 0)))
+       (sbracket "comment" "<!--" "-->"
+        parse-body)))))
 
 (define parse-cdata-section            ;[18,19,20,21]
   (bracketed-region-parser "CDATA section" "<![CDATA[" "]]>"))
index 8b0c2f34361ae53620b71b8d73348d9a1090f50c..e12064f9c71ec4c894ee2f900188ee85a088b7ec 100644 (file)
@@ -1,8 +1,8 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: xml-struct.scm,v 1.6 2002/11/20 19:46:27 cph Exp $
+;;; $Id: xml-struct.scm,v 1.7 2002/12/07 04:14:19 cph Exp $
 ;;;
-;;; Copyright (c) 2001 Massachusetts Institute of Technology
+;;; Copyright (c) 2001, 2002 Massachusetts Institute of Technology
 ;;;
 ;;; This file is part of MIT Scheme.
 ;;;
   attributes
   contents)
 
+(define-structure (xml-comment
+                  (type-descriptor xml-comment-rtd))
+  text)
+
 (define-structure (xml-processing-instructions
                   (type-descriptor xml-processing-instructions-rtd)
                   (print-procedure
index 5c476688893defd561bc986b6bca6444140802ad..e97d28ad631a2b1bcc15e3bfb5179a7806631009 100644 (file)
@@ -1,8 +1,8 @@
 ;;; -*-Scheme-*-
 ;;;
-;;; $Id: xml.pkg,v 1.10 2002/11/20 19:46:27 cph Exp $
+;;; $Id: xml.pkg,v 1.11 2002/12/07 04:13:49 cph Exp $
 ;;;
-;;; Copyright (c) 2001 Massachusetts Institute of Technology
+;;; Copyright (c) 2001, 2002 Massachusetts Institute of Technology
 ;;;
 ;;; This file is part of MIT Scheme.
 ;;;
@@ -38,6 +38,7 @@
          make-xml-!element
          make-xml-!entity
          make-xml-!notation
+         make-xml-comment
          make-xml-declaration
          make-xml-document
          make-xml-dtd
@@ -55,6 +56,7 @@
          set-xml-!entity-value!
          set-xml-!notation-id!
          set-xml-!notation-name!
+         set-xml-comment-text!
          set-xml-declaration-encoding!
          set-xml-declaration-standalone!
          set-xml-declaration-version!
@@ -96,6 +98,9 @@
          xml-!notation-name
          xml-!notation-rtd
          xml-!notation?
+         xml-comment-rtd
+         xml-comment-text
+         xml-comment?
          xml-declaration-encoding
          xml-declaration-rtd
          xml-declaration-standalone