Forum Moderators: open

Message Too Old, No Replies

ASP whitespace before XML declaration!

         

JAB Creations

3:43 am on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I'm trying to parallel my understanding of ASP by learning what I already know in PHP. I design using XHTML 1.1 served as application/xhtml+xml (and in PHP handle media type issues (basically IE)). But right now I'm just working in the text editor with Firefox just to get this working in anything to begin with. So the issue right now is ASP is generating whitespace from the line break. When I remove the line break and put the XML declaration on the same line as ASP's VB code the page renders fine. How can I prevent ASP from adding whitespace from a line break? PHP doesn't create whitespace from this sort of formating of the syntax.

- John

Works without creating whitespace but *BAD* syntax formating practice!

<% Response.ContentType = "application/xml"%><?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>JAB Creations</title>
</head>

<body>

<!--#include file="header.html"-->
<p>content here</p>

<!--#include file="footer.html"-->
</body>
</html>

Broken by adding whitespace but *GOOD* syntax formating practice!

<% Response.ContentType = "application/xml"%>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<title>JAB Creations</title>
</head>

<body>

<!--#include file="header.html"-->
<p>content here</p>

<!--#include file="footer.html"-->
</body>
</html>

carguy84

10:13 pm on Dec 20, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Hey JAB, the ASP in a page is executed before any of the HTML is ever read, so it doesn't matter where you put <% Response.ContentType = "application/xml"%> so long as it's above any other "Response." calls. You could put it between the <head> tags as is common with ASP.NET.

Chip-

JAB Creations

9:51 am on Dec 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



How odd, but thanks! Since it creates a line break I'm just going to do this...

</head>
<!--#include virtual="themes/header.asp"-->
<body>

- John

carguy84

4:17 pm on Dec 21, 2007 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



One other suggestion I would make, when using includes, use virtual instead of file. Then just start every path with / (<!--#include virtual="/includes/header.html"-->)

It will make adding sub directories to the website a lot easier down the road.