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

Re: Using Entity References in XSL Templates

Subject: Re: Using Entity References in XSL Templates
From: Theodore Epstein <Ted.Epstein@xxxxxxxx>
Date: Fri, 21 Jan 2000 12:50:05 -0500
xsl entity nbsp
Mike and David, thanks for the replies.

Part of my problem was that I was using the wrong XSL processor; your
suggestions worked great with XT, but not with MSXML or the parser included
with Object Design's Stylus.

Another part of my problem was that a literal character #160 was
mysteriously coming through not as a non-breaking space, but as a Â
character, which is ANSI #194.  This happens even with XT, unless I set the
output to HTML, in which case XT correctly maps &#160;  to &nbsp;  So I
assume it's something weird with ANSI vs. OEM character mapping on Windows
NT.

Following your advice, I defined nbsp as follows:

    <!DOCTYPE xsl:stylesheet [
        <!ENTITY nbsp "<xsl:text
disable-output-escaping='yes'>&amp;nbsp;</xsl:text>">
    ]>

This worked fine.

In general, I do think there's an argument for allowing entity references
to be passed through.  I understand the inherent problem:  the stylesheet
is an xml document that has to be parsed before the xsl processor sees it,
and entity references are resolved by the parser.  But you might want xml
output with entity references preserved, for example, if the output
document is going to be edited, or piped through an additional processor
that might assign new interpretations to the entities.

The current solution of using <xsl:text> is decent, but I wonder if there
are any plans to make this easier in a future version of XML and XSL.

Regards,

 - Ted


What you can do is ask that character 160 (whether input as
character data, or &#160; or &nbsp;) is output as  &nbsp;
most likely the html output method will do this for you.

If you are using the XML output method there is _no_ reason why you
should want an entity refererence rather than the character, any XML
system will treat them identically if nbsp is defined to be a reference
to character 160.

I don't see the value of outputting &nbsp; rather than &#160;, but for
entity references less trivial than this, I think this is a legitimate use
of

<xsl:text disable-output-escaping="yes">&amp;nbsp;</text>

Mike Kay



David Carlisle wrote:

> > But then the stylesheet processor resolves the entity reference,
>
> No, it never sees the reference, the XML parser it uses to read the
> stylesheet will have expanded it before the XSL system gets the sheet.
> That is what XML parsers are supposed to do.
>
> > I want the entity reference to be *passed through*
> > to the output, which I can't seem to do.
>
> You can't.
>
> What you can do is ask that character 160 (whether input as
> character data, or &#160; or &nbsp;) is output as  &nbsp;
> most likely the html output method will do this for you.
>
> If you are using the XML output method there is _no_ reason why you
> should want an entity refererence rather than the character, any XML
> system will treat them identically if nbsp is defined to be a reference
> to character 160.
>
> David
>
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


 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.