I feel you pain my brother. Put it all on one line.

-----Original Message-----
From: Will Stalder [mailto:skith_diphi@;hotmail.com]
Sent: Thursday, October 24, 2002 12:13 PM
To: CF-Talk
Subject: whitespace woes


I'm having with trouble with ColdFusion and extraneous whitespace.  And
yes, I've done my Google searching.

The problem is that I'm trying to output an XML file, and it's crucial
that there not be any whitespace before the <?xml version="1.0"?>
declaration.

An extremely simplified likeness of my ColdFusion script (with line
numbers, lest e-mail word-wrapping confuse you) is thus:

1 <CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE="Yes"><CFSETTING
ENABLECFOUTPUTONLY="Yes" SHOWDEBUGOUTPUT="No">
2 <CFIF NOT ISDEFINED("do")>
3 <CFOUTPUT>
4 <html><body><form></form></body></html>
5 </CFOUTPUT>
6 <CFELSEIF do EQ "xml"><CFOUTPUT><?xml version="1.0"?>
7 <!DOCTYPE Foo SYSTEM "http://www.foo.com/bar.dtd";>
8 <Foo></Foo>
9 </CFOUTPUT>
10 </CFIF>
11 <CFSETTING ENABLECFOUTPUTONLY="No"></CFPROCESSINGDIRECTIVE>

So this page shows an HTML page with a form on it by default, and if the
form is submitted, it spits out XML.

As you can see, I'm trying at least two different ways to eliminate CF's
whitespace: the SuppressWhitespace and EnableCFOutputOnly.

The problem is that this is what I get from this simplified script (the
problem is the same in my big one):
<?xml version="1.0"?>
<!DOCTYPE Foo SYSTEM "http://www.foo.com/bar.dtd";>
<Foo></Foo>

You'll note the extra space before the <?xml in the first line.  Verrrrry
annoying.

In an attempt to discover why all my attempts at suppressing excess
whitespace failed, I inserted random characters to find out at what point
ColdFusion was inserting that space.  A simplified version follows (note the
extra "1" on the first line):

1<CFPROCESSINGDIRECTIVE SUPPRESSWHITESPACE="Yes"><CFSETTING
ENABLECFOUTPUTONLY="Yes" SHOWDEBUGOUTPUT="No">
<CFIF NOT ISDEFINED("do")>
<CFOUTPUT>
<html></html>
</CFOUTPUT>
<CFELSEIF do EQ "xml"><CFOUTPUT><?xml version="1.0"?>
<!DOCTYPE Foo SYSTEM "http://www.foo.com/bar.dtd";>
<Foo></Foo>
</CFOUTPUT>
</CFIF>
<CFSETTING ENABLECFOUTPUTONLY="No"></CFPROCESSINGDIRECTIVE>

Much to my surprise, the output of this file (with the proper URL inputs)
is:
1<?xml version="1.0"?>
<!DOCTYPE Foo SYSTEM "http://www.foo.com/bar.dtd";>
<Foo></Foo>

Which means the space is being added *before* any of my
whitespace-suppressing measures.

All of which just annoys the heck out of me.  Sure, I can go in and
manually delete that space, but I shouldn't *have* to.

Are there any wise warriors out there that could help here?  To my
knowledge, we're running ColdFusion 4.0 on the server, although I only
recently inherited this project, and I'm not sure.

Thanks,
Todd



~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Signup for the Fusion Authority news alert and keep up with the latest news in 
ColdFusion and related topics. http://www.fusionauthority.com/signup.cfm

Reply via email to