p2p.wrox.com Forums

p2p.wrox.com Forums (http://p2p.wrox.com/index.php)
-   XSLT (http://p2p.wrox.com/forumdisplay.php?f=86)
-   -   Invalid Character in the given encoding (http://p2p.wrox.com/showthread.php?t=71638)

mswin November 28th, 2008 04:17 AM

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.


mhkay November 28th, 2008 04:51 AM

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

mswin November 28th, 2008 05:44 AM


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.

samjudson November 28th, 2008 06:01 AM

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

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

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