[xsl] entities and unwanted namespace information

Subject: [xsl] entities and unwanted namespace information
From: "Tracey Zellmann" <tracey.zellmann@xxxxxxxxxxx>
Date: Tue, 11 Jul 2006 20:53:06 -0400
Regarding my two questions, here is a more appropriate subject line.

Thanks for your response. The copyright now works perfectly. It will take me a little while to digest your other answer, but I am sure I will.

----- Original Message ----- From: "David Carlisle" <davidc@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Tuesday, July 11, 2006 8:37 PM
Subject: Re: [xsl] Two questions




It also is
preceded by another character -  B  The web page then displays B)

It's not preceded by another character, the default output for XSLT (and for XML, generally, is utf8 in which most characters are encodedusing multiple bytes. the copyright symbol is encoded in two bytes, so if you view the file using a utf8 aware system then these two bytes look like a single (c) but if you look at them in a system that thinks it's latin-a then you see two random characters (which in this case happen to be an accented A and the copyright symbol) Your web browser can understabd utf8 so if it is showing incorrectly there most likely you are serving it specifying the encoding is iso-88591. It's possible to fix the web server not todo that but simpler is just to ask xslt to generate in latin-1 by adding <xsl:output encoding="iso-8859-1"/> to your stylesheet.

When I run this, I get the material under the p tag just as I desire, but I
get <p xmlns=""> instead of just <p>

that's because your stylesheet generated p in no-namespace rather than p in the xhtml namespace. Move xmlns="http://www.w3.org/1999/xhtml"; l up on to the xsl:stylesheet element so that it is in scope for teh whole stylesheet (and probably add it to your common.xsl stylesheet as well That would fix things for elements generated by the stylesheet but for html coming from teh source you don't want to copy-of as you need to change th element name (from p-in-no-namespace to p-in-xhtml) so replace

<xsl:copy-of select="content/p"/>

by

<xsl:apply templates mode="xh" select="content/p"/>

and have an xh mode that puts things in xhtml,something like

<xsl:template match="*" mode="xh">
<xsl:element name="{local-name()}"
namespace="http://www.w3.org/1999/xhtml";>
<xsl:apply templates mode="xh" />
</xsl:element>
</xsl:template>

David

Current Thread