XSLT // Special Characters

Posted on 2006-06-06
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
    LVL 60

    Accepted Solution

    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

    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

    Enabling OSINT in Activity Based Intelligence

    Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

    Join & Write a Comment

    Preface In the first article: A Better Website Login System ( I introduced the EE Collaborative Login System and its intended purpose. In this article I will discuss some of the design consideratio…
    Introduction Knockoutjs (Knockout) is a JavaScript framework (Model View ViewModel or MVVM framework).   The main ideology behind Knockout is to control from JavaScript how a page looks whilst creating an engaging user experience in the least …
    The viewer will receive an overview of the basics of CSS showing inline styles. In the head tags set up your style tags: (CODE) Reference the nav tag and set your properties.: (CODE) Set the reference for the UL element and styles for it to ensu…
    HTML5 has deprecated a few of the older ways of showing media as well as offering up a new way to create games and animations. Audio, video, and canvas are just a few of the adjustments made between XHTML and HTML5. As we learned in our last micr…

    729 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

    Need Help in Real-Time?

    Connect with top rated Experts

    19 Experts available now in Live!

    Get 1:1 Help Now