Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old November 28th, 2008, 04:17 AM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default Invalid Character in the given encoding

Hi,

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.

-mswin
Reply With Quote
  #2 (permalink)  
Old November 28th, 2008, 04:51 AM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

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
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer's Reference
Reply With Quote
  #3 (permalink)  
Old November 28th, 2008, 05:44 AM
Registered User
 
Join Date: Nov 2008
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,

Here are the xml and xslt that I am using:
XML:

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


XSLT:

<!--
    - 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:stylesheet
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
      version="1.0">


<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="/">

        <html>

            <head>

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

                <style>
                    body,td {font-family:Tahoma,Arial; font-size:9pt;}
                </style>

            </head>

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

            </body>

        </html>

    </xsl:template>

</xsl:stylesheet>


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.
Reply With Quote
  #4 (permalink)  
Old November 28th, 2008, 06:01 AM
samjudson's Avatar
Friend of Wrox
Points: 8,687, Level: 40
Points: 8,687, Level: 40 Points: 8,687, Level: 40 Points: 8,687, Level: 40
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Aug 2007
Location: Newcastle, , United Kingdom.
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

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 -/
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 12:33 AM.


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