xsl-list
[Top] [All Lists]

Re: Handling ' ' in source xml

2005-09-08 07:17:36

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   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
________________________________________________________________________

--~------------------------------------------------------------------
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>