Using Ant to Apply XSLT

Posted on 2006-04-24
Last Modified: 2013-11-18
I am applying an XSLT to an XHTML document using the ant task xslt i.e.

                <xslt basedir="${tempLoc}" destdir="${tempLoc}"

The problem I have is that the XHTML document contains some non breaking spaces (&nbsp), and once the stylesheet is applied I get some strange characters displayed on my XHTML page.  I am assuming that these strange characters (Â) are some encoded version of this non breaking space ? as it appears to generate "Â&nbsp;"

How do I get these encoded characters treated correctly ?  I am using Linux Redhat ES 3, with Java 1.5.6_06.

The pages are being served by Apache 2.0.55.

I have tried to replace the &nbsp in the source xhtml to &#160, but this has no effect.
Question by:NeilSherman

    Author Comment

    I seem to have found the solution to my own problem!

    The solution is to ensure that the attribute encoding="ISO-8859-1" is within the xsl:output element of your stylesheet!
    LVL 86

    Accepted Solution

    Set the correct output property:

    <outputproperty name="encoding" value="iso8859_1"/>

    (See Ant docs for that task)

    Author Comment

    lol! Beat you too it, but thanks!
    LVL 86

    Expert Comment


    That's slightly different in fact, and means you don't need to depend on the encoding being specified in the stylesheet

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Suggested Solutions

    Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
    Browsers only know CSS so your awesome SASS code needs to be translated into normal CSS. Here I'll try to explain what you should aim for in order to take full advantage of SASS.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    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…

    737 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

    20 Experts available now in Live!

    Get 1:1 Help Now