473,569 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XslCompiledTran sform

Hi

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

System.Text.Enc oderFallbackExc eption: Unable to translate Unicode character
\u2013 at index 3637 to specified code page.
at System.Text.Enc oderExceptionFa llbackBuffer.Fa llback(Char charUnknown,
Int32 index)
at System.Xml.Char EntityEncoderFa llbackBuffer.Fa llback(Char charUnknown,
Int32 index)
....
What exactly is the cause of this, and how can I avoid it?

Thanks,
Peter
Oct 13 '06 #1
3 8017


Peter Kirk wrote:

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

System.Text.Enc oderFallbackExc eption: 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
XmlWriterSettin gs) 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*******@yaho o.deskrev i en meddelelse
news:OR******** ******@TK2MSFTN GP05.phx.gbl...
>

Peter Kirk wrote:

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

System.Text.En coderFallbackEx ception: 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 XmlWriterSettin gs) 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="Windo ws-1252"/>
should do, at least for that particular character you have shown:
<http://www.microsoft.c om/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
4188
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 untouched when I use XslTransform to do the transformation. But after switching to XslCompiledTransform the tabs are transformed to a single space...
1
2604
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 using XslCompiledTransform, the Transform method hangs. My code: Function TransformXML(ByRef FacXML As Xml.XmlDocument, ByVal XslFile As String) As...
6
8087
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 some issues when the xsl file contains scripts. The XslCompiledTransform uses the CodeDom to compile the scripts within the xsl file into .net...
4
9580
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 ? How can I share my XSLT ( there are 2 helper stylesheets, and I check that they are also available... the loaded xsl makes reference to the helper...
12
10076
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) ..... // xsl contents abc.aspx?p1=v1&amp;p2=<xsl:value-of select="$v2" />
1
8021
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 tags that I don’t want, example: * My XSLT has: <script language="javascript" src="client_scripts/VehInInv.js"></script> * Using the...
1
1793
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 page: the new results are visible. Now we are transferring to 2.0 and XslCompiledTransform. The xslt's still work
1
1661
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 StringBuilder(); //Create the XslCompiledTransform and Load it with the xsltDocument XslCompiledTransform xslCompiledTransform = new XslCompiledTransform();
3
5444
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 transform took 4 minutes with XslTransform but 7 minutes with XslCompiledTransform. However, with the same stylesheet on another large complex...
1
1520
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 debugging -xslCompiledTransform(true)- everything works as it should. for example: <Root> <test attr1="avalue" /> <test attr1="anothervalue" />...
0
7694
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7609
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
8118
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7666
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7964
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6278
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
0
5217
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
1
2107
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
936
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.