This is the code I now have which as mentioned outputs in HTML as °
not °:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY deg "°">
<!ENTITY amp "&">]>
<xsl:stylesheet version="1.0"
xmlns:xalan="http://xml.apache.org/xalan"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/1999/xhtml">
<xsl:template match="/">
<html>
<body>
<xsl:apply-templates/>
</body>
</html>
</xsl:template>
<xsl:template match="text()">
<xsl:call-template name="degree"/>
</xsl:template>
<xsl:template name="degree">
<xsl:param name="text" select="."/>
<xsl:choose>
<xsl:when test="contains($text, '°')">
<xsl:value-of select="substring-before($text,'°')"/>
<xsl:text>&deg;</xsl:text>
<xsl:call-template name="degree">
<xsl:with-param name="text"
select="substring-after($text,'°')"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text"/>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
> -----Original Message-----
> From: Joerg Heinicke [mailto:[EMAIL PROTECTED]
> Sent: Thursday, 23 August 2007 12:29 PM
> To: Cocoon Users List
> Cc: [EMAIL PROTECTED]
> Subject: Re: degree symbol from wordml
>
> (Please keep responses to the list even if Cocoon users list might not
> be the best list for this topic.)
>
> First your XSLT is parsed by an XML parser and the entity ° gets
> resolved to the character reference ° which gets resolved to the
> character °. So for the XSLT processor it is actually
> translate(.,'°','°').
>
> Second I can not really explain the difference in behavior of
> serializing ° and the non-breaking space character (to which gets
> resolved). Both are HTML 4 entities [1]. I'm not aware of any special
> entities in the XSLT spec. So it might be just an XSLT processor behavior.
>
> Third, do you have a problem with °? It should also work.
>
> Fourth, the correct way of writing a entity reference to the output is
> by escaping the ampersand: &deg; This is now not parsed to one
> character °, but to 5 characters &, d, e, g and - guess what - ;. You
> can't do this replacement with the translate function anymore but you
> have to switch to a recursive template [2].
>
> Joerg
>
> [1] http://www.w3.org/TR/html401/sgml/entities.html#h-24.2
> [2] http://www.dpawson.co.uk/xsl/sect2/replace.html
>
>
> On 22.08.2007 22:11 Uhr, [EMAIL PROTECTED] wrote:
> > Thanks for the typo.
> > I am just trying to convert "°" to the HTML entity equivalent "°"
> > After further research my approach is currently to use this xsl:
> > <?xml version="1.0"?>
> > <!DOCTYPE xsl:stylesheet [
> > <!ENTITY nbsp " ">
> > <!ENTITY deg "°">
> > ]>
> > ---
> > <xsl:stylesheet version="1.0"
> > xmlns:xalan="http://xml.apache.org/xalan"
> > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> > xmlns="http://www.w3.org/1999/xhtml">
> > <xsl:template match="/">
> > <html>
> > <body>
> > <xsl:apply-templates/>
> > </body>
> > </html>
> > </xsl:template>
> > <xsl:template match="text()" priority="-1">
> > <xsl:value-of select="translate(.,'°','°')"/>
> > </xsl:template>
> > </xsl:stylesheet>
> > ---
> >
> > But "°" doesn't end up in my HTML, it stays as "°".
> > However, it works with ie:
> > <xsl:value-of select="translate(.,'°',' ')"/>
> >
> > So what's the difference between the 2 entities and how can I resolve
> it?
> >
> > Linc
> >
> > Quoting Joerg Heinicke <[EMAIL PROTECTED]>:
> >
> >> On 22.08.2007 3:11 Uhr, Lincoln Mitchell wrote:
> >>
> >>> I am trying to output a degree symbol from wordML.
> >>> It is entered in word as the symbol "Alt+0176" ASCII (Decimal).
> >>> Which in WordML translates to:
> >>> <w:t>°</w:t>
> >>>
> >>> Now, I was hoping to see:
> >>> <w:t>°</w:t>
> >>
> >> Just that (but with a semi-colon at the end: °) should be
> >> sufficient. But you say you have the ° already in the WordML. Why do
> >> you want to handle it at all in your XSLT? What's wrong with
> >> <w:t>°</w:t> compared to <w:t>°</w:t>?
> >>
> >> Joerg
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]