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

Re: nbsp and copy-of and output xml

Subject: Re: nbsp and copy-of and output xml
From: "Andrew Welch" <andrew.j.welch@xxxxxxxxx>
Date: Mon, 18 Aug 2008 10:00:16 +0100
Re:  nbsp and copy-of and output xml
> WHAT I WANT TO PRODUCE: &nbsp; WITH copy-of with output method="xml"

The short answer is "you can't" - but there's usually no need to.

The XSLT processor operates on an input tree.  That tree is built by
the XML parser, which when it encounters the entity "nbsp" (or any
entity) it will expand it to the value that entity represents... #160
in this case.  So when the XSLT processor gets involved, there is no
nsbp to copy, just it's expanded value #160.  The XSLT has no idea
whether that value came from entity expansion, or was written directly
in the XML.

The usual reason people want nbsp in their output is because #160 is a
2 byte character in UTF-8 and results in spurious characters appearing
in the output, like a-with-circumflex.  This is simply an encoding
issue, and well worth understanding and fixing.  Outputting #160 is
the right thing to do, if its highlighting an encoding problem then
fix that rather than hack an nbsp into the output (which sadly seems
to be nearly always the route chosen).

If you really do need to output entity references, I've (almost)
written a small utility which converts lexical events into markup,
such as entity references and cdata sections, so you would get:

<lexev:entity name="nbsp"> </lexex:entity>

(which the space is the expanded value of #160)

...which is then easy to process with XSLT.



-- 
Andrew Welch
http://andrewjwelch.com
Kernow: http://kernowforsaxon.sf.net/

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.