Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium


XSLT // Special Characters

Posted on 2006-06-06
Medium Priority
Last Modified: 2013-11-18
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?

Question by:go4java
  • 2
LVL 60

Accepted Solution

Geert Bormans earned 2000 total points
ID: 16841611
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;"/>

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

LVL 60

Expert Comment

by:Geert Bormans
ID: 16841627

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)


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

and then you can address that this way


document('') helps you addressing inside the stylesheet


Featured Post

Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

What is Node.js? Node.js is a server side scripting language much like PHP or ASP but is used to implement the complete package of HTTP webserver and application framework. The difference is that Node.js’s execution engine is asynchronous and event…
SASS allows you to treat your CSS code in a more OOP way. Let's have a look on how you can structure your code in order for it to be easily maintained and reused.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
The viewer will learn how to dynamically set the form action using jQuery.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question