When writing processing instructions, don't emit space after name
authorChris Hanson <org/chris-hanson/cph>
Thu, 26 Jan 2006 05:53:49 +0000 (05:53 +0000)
committerChris Hanson <org/chris-hanson/cph>
Thu, 26 Jan 2006 05:53:49 +0000 (05:53 +0000)
unless needed.

v7/src/xml/xml-output.scm

index 72b789b62b438ce01567183a314dab934cfc0e2f..c70590a6bfaed0cdd02a983a56f92c8c682629b2 100644 (file)
@@ -1,6 +1,6 @@
 #| -*-Scheme-*-
 
-$Id: xml-output.scm,v 1.37 2005/12/19 04:11:32 cph Exp $
+$Id: xml-output.scm,v 1.38 2006/01/26 05:53:49 cph Exp $
 
 Copyright 2001,2002,2003,2004,2005 Massachusetts Institute of Technology
 
@@ -163,8 +163,13 @@ USA.
 (define-method %write-xml ((pi <xml-processing-instructions>) ctx)
   (emit-string "<?" ctx)
   (write-xml-name (xml-processing-instructions-name pi) ctx)
-  (emit-string " " ctx)
-  (emit-string (xml-processing-instructions-text pi) ctx)
+  (let ((text (xml-processing-instructions-text pi)))
+    (if (fix:> (string-length text) 0)
+       (begin
+         (if (not (char-set-member? char-set:xml-whitespace
+                                    (string-ref text 0)))
+             (emit-string " " ctx))
+         (emit-string text ctx))))
   (emit-string "?>" ctx))
 \f
 (define-method %write-xml ((dtd <xml-dtd>) ctx)