RE: [xsl] Problem with rendering of &#160

Subject: RE: [xsl] Problem with rendering of &#160
From: Richard.McMillian@xxxxxxxx
Date: Wed, 14 Apr 2004 13:56:45 -0600
This thread addressed the problem back in 2002.  Has anyone come across a
better solution?

-----Original Message-----
From: Richard.McMillian@xxxxxxxx [mailto:Richard.McMillian@xxxxxxxx]
Sent: Tuesday, April 13, 2004 11:44 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: jcouture@xxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Problem with rendering of &#160

Thanks for info Tom, however with the change you suggested for the XSL, the
resulting HTML output still has this:
<META http-equiv="Content-Type" content="text/html; charset=UTF-16">

The charset=UTF-16 is not the issue.  It is the content="text/html that
causes the
mal-rendering.  Is there an option to give the microsoft parser not to
to this content value?

function GenOrder(xmlstr, xslfile)
  dim xml, xsl, xslFileName, htmlDoc, tstr
  set xml = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
  xml.async = FALSE
  xml.validateOnParse    = FALSE
  xml.resolveExternals   = FALSE
  xml.preserveWhiteSpace = False
   WriteToLog ("GenOrder xmlstr = " & xmlstr)
   WriteToLog ("GenOrder xslfile = " & xslfile)
  if xml.LoadXML(xmlstr) then
    set xsl = Server.CreateObject("MSXML2.FreeThreadedDOMDocument.3.0")
    xsl.async = false
    xslFileName = Server.MapPath(xslfile)
    if xsl.parseError.errorCode <> 0 then
      tstr = "<pre>XML Doc XSL Error" & vbCRLF _
           & "Reason: " & xsl.parseError.reason  & vbCRLF _
           & "Line: "   & xsl.parseError.line    & vbCRLF _
           & "Src: "    & xsl.parseError.srcText & vbCRLF _
           & "</pre>"
      tstr = xml.transformNode(xsl)
    end if
    end if
  set xsl = nothing
  set xml = nothing
  GenOrder = tstr
end function 
-----Original Message-----
From: Passin, Tom [mailto:tpassin@xxxxxxxxxxxx]
Sent: Tuesday, April 13, 2004 3:53 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx; xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc: jcouture@xxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] Problem with rendering of &#160

From: Richard.McMillian@xxxxxxxx [mailto:Richard.McMillian@xxxxxxxx]
I have a problem with non-breaking space being rendered as a "?" question
mark by the IE webbrowser.
I looked at the output html and the hex character is A0 as is is supposed to
be; however the XSL automatically inputs
<META http-equiv="Content-Type" content="text/html; charset=UTF-16"> after
the header.   Changing the Content
value to iso-8859-1 results in the correct rendering of the A0.  Where does
the XSL derive this META tag
value from?  I've included an XML sample and the XSL code below.

-- Getting utf-16 by default has nothing to do with xslt - it is a
characteristic of the Microsoft xml/xslt processor, depending on how it is
used.  Getting the display you do is a tipoff that your browser does not
support that character in its own default encoding.  IE (in the US, anyway)
is generally expecting iso-8859-1,  so you get the nonbreaking space
rendering as intended when you use that encoding.

However, you have an error in the stylesheet.  You used a wrong encoding
value in the xsl:output element.  You should write

<xsl:output method="html" encoding="iso-8859-1"/>

An encoding of "text" is not a recognized character encoding, and I am
surprised you did not get an error from the processor.  Also, with the html
output method, you don't need to omit the xml declaration - since the output
is gong to be html and not xml, the xml declaration will not be inserted


Tom P

Current Thread