Almost there...

Quoting Joerg Heinicke <[EMAIL PROTECTED]>:

(Please keep responses to the list even if Cocoon users list might not
be the best list for this topic.)

Sorry, I noticed after I sent it that it wasn't sent to the list - so
did so just before I read this email.


First your XSLT is parsed by an XML parser and the entity &deg; gets resolved to the character reference &#176; which gets resolved to the character °. So for the XSLT processor it is actually translate(.,'°','°').

Ahhh! I didn;t realise, ofcourse now the behaviour makes sense.

Third, do you have a problem with °? It should also work.

No. Words fine.

Fourth, the correct way of writing a entity reference to the output is by escaping the ampersand: &amp;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].

I also added <!ENTITY amp "&#38;">, tried it, but &amp;deg; outputs in
HTML as &amp;deg; not &deg;

Linc


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 "&deg"
After further research my approach is currently to use this xsl:
<?xml version="1.0"?>
  <!DOCTYPE xsl:stylesheet [
   <!ENTITY nbsp "&#160;">
   <!ENTITY deg "&#176;">
   ]>
---
<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(.,'°','&deg;')"/>
 </xsl:template>
</xsl:stylesheet>
---

But "&deg;" doesn't end up in my HTML, it stays as "°".
However, it works with &nbsp; ie:
<xsl:value-of select="translate(.,'°','&nbsp;')"/>

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>&#176</w:t>

Just that (but with a semi-colon at the end: &#176;) 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>&#176;</w:t>?

Joerg




----- End forwarded message -----



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to