|
Subject: Re: [xsl] Yet Another Entity Ref question! From: Marco Guazzone <sguazt@xxxxxxxxxxx> Date: Fri, 20 Dec 2002 09:19:32 +0100 (CET) |
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. "
" or "à"), 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 "©", from XML to HTML
> > through XSLT;
>
> Put Unicode character #169 (the copyright symbol) in your stylesheet
> with © or ©
>
> 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 ©
> or an entity reference like ©.
>
> You won't be able to control whether the processor emits © or
> ©, 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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] Yet Another Entity Ref qu, Mike Brown | Thread | Re: [xsl] Yet Another Entity Ref qu, David Carlisle |
| Re: [xsl] Function id() does not wo, G. Ken Holman | Date | RE: [xsl] Sample Code for multiple , Renzo Callant |
| Month |