469,929 Members | 1,883 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,929 developers. It's quick & easy.

XslCompiledTransform

Hi

I am trying to exexute a transform (XslCompiledTransform .Transform), but
get this exception:

System.Text.EncoderFallbackException: Unable to translate Unicode character
\u2013 at index 3637 to specified code page.
at System.Text.EncoderExceptionFallbackBuffer.Fallbac k(Char charUnknown,
Int32 index)
at System.Xml.CharEntityEncoderFallbackBuffer.Fallbac k(Char charUnknown,
Int32 index)
....
What exactly is the cause of this, and how can I avoid it?

Thanks,
Peter
Oct 13 '06 #1
3 7637


Peter Kirk wrote:

I am trying to exexute a transform (XslCompiledTransform .Transform), but
get this exception:

System.Text.EncoderFallbackException: Unable to translate Unicode character
\u2013 at index 3637 to specified code page.
What output encoding are you trying to transform to? It sounds as if the
result tree contains the Unicode character with hex code 2013 '–'
(decimal 8211) and that character is not contained in the code page you
want to use (e.g. with <xsl:output encoding="ISO-8859-1"or
XmlWriterSettings) so serializing the result tree with the desired
encoding fails.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Oct 13 '06 #2

"Martin Honnen" <ma*******@yahoo.deskrev i en meddelelse
news:OR**************@TK2MSFTNGP05.phx.gbl...
>

Peter Kirk wrote:

>I am trying to exexute a transform (XslCompiledTransform .Transform), but
get this exception:

System.Text.EncoderFallbackException: Unable to translate Unicode
character \u2013 at index 3637 to specified code page.

What output encoding are you trying to transform to? It sounds as if the
result tree contains the Unicode character with hex code 2013 '-' (decimal
8211) and that character is not contained in the code page you want to use
(e.g. with <xsl:output encoding="ISO-8859-1"or XmlWriterSettings) so
serializing the result tree with the desired encoding fails.
Well see, I know virtually nothing about these aspects. I have been supplied
with an xslt file which contains this line:

<xsl:output method="text" encoding="iso-8859-1"/>

I have written a method which accepts an xml string (which consists of data
extracted from a database), and tries to transform this xml to csv format
using an xslt file (supplied by someone else). Could the problem be in the
"encoding" specified in the xslt? Or is it the xml data? What can I do to
avert the exception?

The transformation works with some data, but fails with other data. So it
appears there are some characters in some data which the transformation/xslt
cannot handle, but I don't really know where a fix for this should reside.

Thanks,
Peter
Oct 13 '06 #3


Peter Kirk wrote:

Well see, I know virtually nothing about these aspects. I have been supplied
with an xslt file which contains this line:

<xsl:output method="text" encoding="iso-8859-1"/>

I have written a method which accepts an xml string (which consists of data
extracted from a database), and tries to transform this xml to csv format
using an xslt file (supplied by someone else). Could the problem be in the
"encoding" specified in the xslt? Or is it the xml data? What can I do to
avert the exception?
The problem is that the XSLT stylesheet tries to output the character
'' but that character is not contained in ISO-8859-1. Whether that
character is copied from the input or contained literally in the
stylesheet does not matter.

Use
<xsl:output method="text" encoding="UTF-8"/>
then you should not have any problems as UTF-8 as an Unciode encoding
can handle all Unicode characters.
Alternatively if you want text in a 8bit Windows code page then doing e.g.
<xsl:output method="text" encoding="Windows-1252"/>
should do, at least for that particular character you have shown:
<http://www.microsoft.com/globaldev/reference/sbcs/1252.mspx>
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Oct 13 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

6 posts views Thread by W. Jordan | last post: by
4 posts views Thread by andrewcw | last post: by
1 post views Thread by Hans Kesting | last post: by
1 post views Thread by Mark | last post: by
1 post views Thread by =?Utf-8?B?d2VqaXY=?= | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.