xsl-list
[Top] [All Lists]

Re: [xsl] Entities in XSL (again)

2010-02-17 11:18:22
Ken,
Thanks. I used the nbsp as a sample but was thinking also about non HTML 
entities but this is great for those entities that are defined in HTML. I sort 
of forgot about the html method which makes all if this very simple.
Terry 



----- Original Message ----
From: G. Ken Holman <gkholman(_at_)CraneSoftwrights(_dot_)com>
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Sent: Wed, February 17, 2010 11:50:54 AM
Subject: Re: [xsl] Entities in XSL (again)

At 2010-02-17 07:36 -0800, Terry Badger wrote:
Thank you. I thought I could get the stylesheet to declare the 'missing' 
entity in the xml file but that is the duty of the xml file and the parser 
would get this problem before the stylesheet got it. I can just use 
disable-output-escaping to put that entity in if needed on the output.

Ouch!

That is not the use case for disable-output-escaping="yes".

The entity "&nbsp;" is from an entity set used by HTML.  The HTML serialization 
recognizes this and is supposed to use the entity name when the result tree is 
serialized:

http://www.w3.org/TR/2007/REC-xslt-xquery-serialization-20070123/#HTML_CHARDATA
  Entity references and character references SHOULD be used only
  where the character is not present in the selected encoding, or
  where the visual representation of the character is unclear (as
  with &nbsp;, for example).

However you declare or use the entity in the XML file, if the result tree text 
node has &#x160; and you are using HTML serialization, then you should get what 
you want.

Now if you want to serialize your result tree as XML then you may be stuck:  
using disable-output-escaping="yes" for &nbsp; will produce a non-well-formed 
result because there is no entity declaration.  Unless, perhaps, you are using 
standard XSLT to add the DOCTYPE declaration pointing to an external 
declaration subset that includes a declaration for that entity.

I hope this helps.

. . . . . . . . . . Ken


--
XSLT/XQuery/XPath training after http://XMLPrague.cz 2010-03-15/19
XSLT/XQuery/XPath training:  San Carlos, California 2010-04-26/30
Vote for your XML training:  http://www.CraneSoftwrights.com/s/i/
Crane Softwrights Ltd.          http://www.CraneSoftwrights.com/s/
Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video
Video lesson:    http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18
Video overview:  http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18
G. Ken Holman                mailto:gkholman(_at_)CraneSoftwrights(_dot_)com
Male Cancer Awareness Nov'07  http://www.CraneSoftwrights.com/s/bc
Legal business disclaimers:  http://www.CraneSoftwrights.com/legal


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--


      

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>