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

Re: Handling ' ' in source xml

Subject: Re: Handling ' ' in source xml
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 8 Sep 2005 15:17:36 +0100
xml nbsp
> I hope this isn't covered in the nbsp faq and I'm just
> not seeing it... :(

er yes this is exactly the issue the faq tries to cover:-)

It's very hard to get a faq on nbsp, as if people see what's
happening enough to know what question to look up in the faq, then they
don't have a problem any more:-)

> Basically the source xml i'm converting to xml, has a
> lot of &nbsp; sequences in it.

That could mean one of two things.

Either you have a documennt like

<foo> ... &nbsp; ... </foo>

or you have a document like

<!DOCTYPE foo SYSTEM "some dtd that defines nbsp, most likley to being #160">
<foo> ... &nbsp; ... </foo>


In the first case all bets are off: your input is not well formed, and
you will get a fatal parse error from _any_ XML application, XSLT
included.

In the second case all you need remember is that the input is processed
by an XML parser _before_ XSLT sees it and XML parsers replace character
and entityreferences by the characters that they reference. So here the
input to XSLt does _not_  have an nbsp entity reference, it has a
character as literal data, just as if it had been typed at the keyboard.

The character is number 160, so if your editor allows yoyu to enter
characters by number you can just do that, or you can use a numeric
character reference such as & # 1 6 0 ; which again will be processed by
teh XML parser (when parsing the stylesheet) so XSLT will see the actual
character not the character reference.

text()[contains(self::node(), '& # 1 6 0 ;')]

or nore simply

text()[contains(., '& # 1 6 0 ;')]

or (perhaps, depending on context)

contains(text(), '& # 1 6 0 ;')

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

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.