473,395 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

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 7978


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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Eckhard Schwabe | last post by:
when switching from the old "XslTransform " to "XslCompiledTransform" I notice a difference in the handling of whitespace. I need to transform a XML file which contain tabs (\t), and which remain...
1
by: Steve | last post by:
Using VB.NET 2.0 I have a simple routine that attempts transforms an XmlDocument with an XSLT stylesheet into HTML. Under the old 1.1 framework with XslTransform, everything worked fine. Now...
6
by: W. Jordan | last post by:
Hello there, Are there anybody who is using the XslCompiledTransform that comes with .net framework, which was said to be a replacement of the XslTransform class? I found that the class has...
4
by: andrewcw | last post by:
I am moving some code forward from .NET 1.1. I was able to load the XSL file and perform the transform. The MSDN documentation looks like it should be easy. But I get a compile error. Ideas ?...
12
by: InvalidLastName | last post by:
We have been used XslTransform. .NET 1.1, for transform XML document, Dataset with xsl to HTML. Some of these html contents contain javascript and links. For example: // javascript if (a &gt; b)...
1
by: mikepmyers | last post by:
I've done some research online and turned up with results that did not sit well with me. I’m using the System.Xml.XslCompiledTransform class as recommended by MS; however, it’s creating self-closing...
1
by: Hans Kesting | last post by:
Hi, In our ASP.Net webapplications, we use xslt a lot. For 1.1 developing was "easy": start up the website and go to the page where the xslt was used. Change the xslt (save it) and refresh the...
1
by: Mark | last post by:
I'm getting the error "The URI scheme is too long." in the code below. What is URI in this context? The XSL or the XML being transformed? Thanks! -Mark StringBuilder sb = new...
3
by: Andy Fish | last post by:
Hi, From reading the documentation, I get the impression that XslCompiledTransform should be faster than XslTransform on my test with a large complex document and a large complex XSLT, the...
1
by: =?Utf-8?B?d2VqaXY=?= | last post by:
When I use xslCompiledTransform() or xslCompiledTransform(false) I find that the XPath queries in my select query attributes do not recognize any attributes inthe xml document. But when I enable...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.