[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

RE: [xsl] Escape caracters


Subject: RE: [xsl] Escape caracters
From: "SMITH Neil" <neil.smith@xxxxxxxx>
Date: Tue, 1 Jun 2004 12:49:28 +0200

> > From: Passin, Tom [mailto:tpassin@xxxxxxxxxxxx] 
>  
> > From: SMITH Neil [mailto:neil.smith@xxxxxxxx] 
> > This is the XSL
> > 
> > <?xml version="1.0" encoding="UTF-8"?>
> > <xsl:stylesheet version="1.0" 
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
> > 
> > <xsl:template match="/">
> > 
> > <META HTTP-EQUIV="Content-Type" CONTENT="text/html; 
> > charset=UTF-8"/> <html> <body>
> > 
> > <xsl:apply-templates select=".//RR_row"/>
> > 
> > </body>
> > </html>	
> > </xsl:template>
> > 
> > etc...
> > 
>
> As David Carlisle has just posted, this produces invalid HTML.  Also, do
> you intend to be producing *XHTML* or *HTML*?  You are doing neither
> right now.
>
> To expand on what David said about doubled escaping, he means that the
> ampersand in the character references is itself escaped with & a m p ;.
> Thus the things that look like character references are only text, and
> the browser shows them just as the output file specifies.
>
> Assuming that you want to generate real HTML, you do not have to put
> your own meta element in, the processor will do it if you simply use an
> xsl:output element to say what the encoding is and that you want html
> output.  Normally, the processor wouuld create html by default when it
> notices the html element, but in this case, you start with a meta
> element, and that apparently has prevented the processor from realizing
> what you want.  
>
> The only reason you are getting anything viewable in the browser is
> because browsers are so very tolerant of junk.
>
> Cheers,
>
> Tom P

Hi guys!
Hope you had a nice week-end!!!
I tried to take the meta stuff out and only put an xsl:output element, and I now have something like this in my xsl:

<?xml version="1.0" encoding=" ISO-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:output 
                      method="html"
                      encoding="ISO-8859-1"/>
                      
<xsl:template match="/">

<html>
<body>

<xsl:apply-templates select=".//RR_row"/>

</body>
</html>	
</xsl:template>

Which generates this HTML file

<html><body><p><i><b>AEBI PHILIPP, Assoziierte(r) Professor(in)</b></i></p><p>Festkörperphysik</p>		<p />
		<p style="margin-left:36.0pt"><i>Publications</i></p><p style="margin-left:72.0pt">A. Züttel, Ch. Nützenadel, P. Sudan, Ph. Mauron, Ch. Emmenegger, S. Rentsch, L. Schlapbach, A. Weidenkaff and T. Kiyobayashi, "Hydrogen sorption by carbon nanotubes and other carbon nanostructures",
J. Alloys and Comp. 330-332, 676 (2002)</p><p style="margin-left:72.0pt">L.O. Nilsson, O. Gröning, P. Gröning and L. Schlapbach
Collective emission degradation behavior of carbon nanotube thin film electron emitters, Appl. Phys. Lett. 79, 1036 (2001)</p><p style="margin-left:72.0pt">O. Gröning, L.O. Nilsson, P. Gröning and L. Schlapbach
Properties and characterization of CVD diamond field emitters
Solid State Electronics 45, 929(2001)</p>


Does this look better?

And about the double escaping, the problem is that these are saved as is (&#8220;) in the database (via a web application). So the problem seems not to be with the transformation... But I still don't understand why these 'caracters' are displayed correctly while querying the data directly from the web application, and not while displaying the html generated from xml in a browser.


Current Thread
Keywords