Forum Moderators: open

Message Too Old, No Replies

ASP adding META tag to XSL template

Changing the charset and not valid XHTML

         

Hester

2:29 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



I am using ASP to process an XML file via an XSL template, but the output has the addition of a META tag as below!

<META http-equiv="Content-Type" content="text/html; charset=UTF-16">

I would like the outputted code to be XHTML-compliant, and also to use UTF-8. But I cannot see a way to stop ASP adding the above line.

If I add the META tag manually, then I end up with two!

What is the solution?

mrMister

2:41 pm on Jul 21, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



As a quick and dirty fix, I'd be tempted to remove it using a regular expression. something like...

<META?*+?>

And then add your own appropriate HTTP headers (Don't use Meta tags, it's dirty).

Don't use UTF-8 unless your document is actually encoded using UTF-8

mattglet

12:25 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Is this your own XSL template? I would look in the file to see if the tag is located there.

Hester

2:34 pm on Jul 22, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



After studying the XSL specs and various tutorials, I've discovered the 'output' declaration, which can add a META tag to the document. It's supposed to also use the charset given, eg: UTF-8, but it doesn't work for me. I always see UTF-16.

Note: in none of the files is a META tag or output set.

I then discovered that the META tag was only added when there was a HEAD tag in the XSL template. If I just had HTML then BODY, it would not add a META tag. This mirrors what the specs say here [w3.org]:

The encoding attribute specifies the preferred encoding to be used. If there is a HEAD element, then the html output method should add a META element immediately after the start-tag of the HEAD element specifying the character encoding actually used.*

I cannot find any way to control the contents of the META tag added, no matter what output or method I declare in the XSL template. So either I'm missing something or it's a bug in ASP or the server is set to give UTF-16.

*Hmm, does that mean what the server is sending? I get "- not supplied - (windows-1252)".

I can't wait for XSL 2.0 which adds an XHTML output type!