[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Yet Another Entity Ref question!

Subject: Re: Yet Another Entity Ref question!
From: Marco Guazzone <sguazt@xxxxxxxxxxx>
Date: Fri, 20 Dec 2002 09:19:32 +0100 (CET)
copyright entity
Thanks Mike!!
However the problem is more general; suppose you have a content management
engine that takes as input an XML, applies an XSL and produces an HTML.
So an unknown user write an XML sheet (following a well-known grammar);
inside this sheet he/she can put an element like
     <entity>ent</entity>
where "ent" can be numberi (e.g. "#x0A") or symbolic (e.g. "agrave").
The engine should transform this element into the entity reference "&ent;"
(e.g. "&#x0A;" or "&agrave;"), through an XSL template like:

<xsl:template match="entity">
  <xsl:text
disable-output-escaping="yes"><![CDATA[&]]></xsl:text><xsl:value-of
select="." /><xsl:text>;</xsl:text>
</xsl:template>

the problem arises when I use the result of this template; if the result
is taken as-is, I will get the right thing ("&ent;"); if the result is
stored inside a variable I have to disable-output-escaping when using
xsl:value-of. For example

XML
...
<doc>
  <label>Foobar<entity>ent</entity></label>
</doc>

XSL:
...
<xsl:template match="doc">
   <xsl:apply-templates select="label" /> <!-- ok! -->
   <xsl:variable name="label">
      <xsl:apply-templates select="label" />
   </xsl:variable>
   <xsl:value-of select="$label" />  <!-- not ok -->
   <xsl:value-of disable-output-escaping="yes" select="$label" />  <!-- ok
-->
</xsl:template>
...

So I can't substitute the value of the entity with the related UNICODE
representation because I don't know that entity.
Any idea?
Thanks so much!!

On Thu, 19 Dec 2002, Mike Brown wrote:

> Marco Guazzone wrote:
> > I'd like to produce an entity reference, say "&copy;", from XML to HTML
> > through XSLT;
> 
> Put Unicode character #169 (the copyright symbol) in your stylesheet
> with &#169; or &#xA9;
> 
> Change your output encoding to us-ascii to ensure that the XSLT processor
> won't emit that character directly encoded. ASCII does not have a copyright 
> symbol, so the processor will emit a numeric character reference like &#169; 
> or an entity reference like &copy.
> 
> You won't be able to control whether the processor emits &#169; or
> &copy;, but I believe most XSLT processors try to emit entity refs when
> the character falls in the latin-1 range and isn't able to be expressed
> directly in the given encoding.
> 
> Mike
> 
> -- 
>   Mike J. Brown   |  http://skew.org/~mike/resume/
>   Denver, CO, USA |  http://skew.org/xml/
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 
> 

--------------------------------
Marco Guazzone   
Software Engineer
Kerbero S.r.L. - Gruppo TC
Viale Forlanini, 36 
Garbagnate M.se (MI)
20024 - Italy
mail: marco.guazzone@xxxxxxxxxxx
www: http://www.kerbero.com
Tel. +39 02 99514.247
Fax. +39 02 99514.399
--------------------------------



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.