XSLT // Special Characters

Hi Gertone (since you seem to be the only XML expert in this forum ;-)
What is the best way to include a MAPPING TABLE of special characters (e.g.   => ..160) in XSLT file?
Ciao

go4javaAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Geert BormansInformation ArchitectCommented:
Hi go4java,

> since you seem to be the only XML expert in this forum ;-)
well, there are quiet a few others

There are three options for doing what you want,
depending on where you need it

- use the entity resolution mechanism of the parser on the source file
- use the entity resolution mechanism of the parser on the XSLT
- use a lookup table in the XSLT

If you have the   in your source file, you need to have a DOCTYPE declaration
like this
<!DOCTYPE root [
<!ENTITY nbsp "&#160;"/>
]>
<root>.... (with root being your root element)
If not, your XML will not be wellformed, and the XSLT processing cannot start

If you need different mappings, then you can change the resolution values in the ENTITY definitions

If you don't have such a DOCTYPE
and you do have &nbsp; in your source you need to filter them out before hand,
or create the entity definitions

If you have entities like this in your XSLT
you can use the same mechanism on the XSLT
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp "&#160;"/>
]>
<xsl:stylesheet....

Note that this is the easiest answer to your question
because the parser solves the problem for you

Cheers!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Geert BormansInformation ArchitectCommented:
go4java,

a quick word on lookups

you can have a snippet in your XSLT
that is in a different namespace
(in between templates, or at the end)

eg.

<map:entity source="&nbsp;" result="&#160;" />

and then you can address that this way

document('')//map:entity[@source='&nbsp;']/@result

document('') helps you addressing inside the stylesheet

cheers
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Web Languages and Standards

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.