Forum OpenACS Q&A: Leding space in APD pages

Collapse
Posted by Andrei Popov on
In all generated pages the first line always starts with a space. Even if I don't use a master on a particular page, and my .ADP looks like:
<?xml version="1.0"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"file:///d:/cygwin/usr/local/lib/xml/dtd/xhtml/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>....
I end up with this when the page is actually generated:
 <?xml version="1.0"?>
<!DOCTYPE html
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"file:///d:/cygwin/usr/local/lib/xml/dtd/xhtml/xhtml1-transitional.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  <head>
    <title>...
</pre>

Tidy and xsltproc do not like this:

$ xsltproc xhtml2fo.xsl table-all.html > table.fo
table-all.html:1: error: XML declaration allowed only at the start of the document
 <?xml version="1.0"?>
     ^
unable to parse table-all.html
Of course I can always remove that little space using sed or some other filter before passing the data onto xsltproc, but would one think there should be a way to simply not have it there? My guess is that ACS Templating puts it in, I just can't figure out why...
Collapse
Posted by Andrei Popov on
...oops...
Collapse
Posted by Torben Brosten on
I am seeing a space inserted before doctype tags on standard adp pages (and it exists on the openacs.org website also).

blank-master.adp and default-master.adp do not have a leading space before the doctype tag.

Any idea where this originates from? Andrei?

Collapse
Posted by Andrei Popov on

I think it is put there in acs-templating somewhere, not sure where though. I guess it would be worth to look at compiled template and see if there's anything that might cause this.

I had a problem with this only because I was doing some post-processing using xsltproc on the generated page. Ended up doing a (quick'n dirty) sed -i 's/^ <!DOCTYPE/<!DOCTYPE/' on the wget'ed file...

Collapse
Posted by Jeff Davis on
I fixed this a while back on HEAD.  I will see if I can track down the commit.
Collapse
Posted by Jeff Davis on
Here it is:
cvs diff -u -r1.10 -r 1.11 acs-integration-procs.tcl
Index: acs-integration-procs.tcl
===================================================================
RCS file: /cvsroot/openacs-4/packages/acs-templating/tcl/acs-integration-procs.tcl,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -r1.10 -r1.11
--- acs-integration-procs.tcl   1 Oct 2003 14:51:41 -0000       1.10
+++ acs-integration-procs.tcl   10 Oct 2003 19:15:04 -0000      1.11
@@ -5,7 +5,7 @@
 # Copyright (C) 1999-2000 ArsDigita Corporation
 # Authors: Christian Brechbuehler <christian@arsdigita.com

-# $Id: acs-integration-procs.tcl,v 1.10 2003/10/01 14:51:41 lars Exp $
+# $Id: acs-integration-procs.tcl,v 1.11 2003/10/10 19:15:04 jeffd Exp $

 # This is free software distributed under the terms of the GNU Public
 # License.  Full text of the license is available from the GNU Project:
@@ -158,7 +158,7 @@

         set mime_type [template::get_mime_type]
         set header_preamble [template::get_mime_header_preamble $mime_type]
-       doc_return 200 $mime_type "$header_preamble $parsed_template"
+       doc_return 200 $mime_type "$header_preamble$parsed_template"
     } else {
         db_release_unused_handles
     }
Collapse
Posted by Torben Brosten on
Wow, I dreaded the thought of tracking down this bug. Thanks, Jeff!