Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old November 28th, 2008, 04:17 AM
Registered User
Join Date: Nov 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Invalid Character in the given encoding


I am using XSLT to process an XML document.
In my xslt code I have the following line of code, for which I am getting the error as "Invalid Character in the given encoding".

<xsl:value-of select="Ø"/>

XSl Output tag in my xslt:
<xsl:output method="html" />

Anything Wrong with this?

Thanks in Advance for any suggetsions.

Old November 28th, 2008, 04:51 AM
mhkay's Avatar
Wrox Author
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts

From the error message as given, it's not clear whether the problem is with the source document, the stylesheet, or the output document. Are there no other clues? (If not, another XSLT processor might give better diagnostics...).

My first guess would be that the problem is with the stylesheet itself, that you have edited it using an editor whose default encoding is iso 8859-1 but you haven't added an XML declaration at the start of the stylesheet to say so. See what happens if you add <?xml version="1.0" encoding="iso-8859-1"?>

Michael Kay
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Old November 28th, 2008, 05:44 AM
Registered User
Join Date: Nov 2008
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts


Here are the xml and xslt that I am using:

 <?xml version="1.0" encoding="iso-8859-1" ?>
  <name>XYZ Inc.</name>
  <address1>One Abc Way</address1>
  <address2>Some avenue</address2>
  <city>Tech city</city>


    - XSLT is a template based language to transform Xml documents
    It uses XPath to select specific nodes
    for processing.

    - A XSLT file is a well formed Xml document


<xsl:output method="html" />

        Main template to kick off processing our Sample.xml
        From here on we use a simple XPath selection query to
        get to our data.
    <xsl:template match="/">



                <title>Welcome to <xsl:value-of select="/company/name"/></title>

                    body,td {font-family:Tahoma,Arial; font-size:9pt;}


                <h2>Welcome to <xsl:value-of select="/company/name"/></h2>
                <b>Our contact details:</b>
                <xsl:value-of select="/company/name"/>
                <xsl:value-of select="/company/address1"/>
                <xsl:value-of select="/company/address2"/>
                <xsl:value-of select="/company/city"/>
                <xsl:value-of select="/company/country"/>
                <xsl:value-of select="Ø"/>





I am using XSLTCompiledTransform in C#, and writing result to html file.

Even I added encoding to the xml file it doesn't work. Still I get the same error.

Many thanks for further help on this.
Old November 28th, 2008, 06:01 AM
samjudson's Avatar
Friend of Wrox
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts

Michael was suggesting adding the XML declaration to the XSLT file.

Without that declaration the XML file is NOT well-formed if the file is assumed to be UTF-8 (I cut and pasted it into Notepad++ and used its XML syntax checker and it told me straight away that that line had an invalid character).

/- Sam Judson : Wrox Technical Editor -/

Similar Threads
Thread Thread Starter Forum Replies Last Post
ORA-00911: invalid character cpajoe2001 Oracle ASP 2 August 18th, 2008 06:52 AM
encoding problem with arabic character farukcse Pro PHP 0 November 15th, 2007 04:44 PM
% is an invalid character? owoade .NET Web Services 1 August 12th, 2007 12:32 PM
Invalid char in encoding-new asp .net webservice ajcis55 C# 1 April 12th, 2007 04:42 AM
An invalid character was found in text content crmpicco Excel VBA 2 May 4th, 2005 04:43 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.