XSL transformation on XML data in SQL 2005 causes 'invalid character' error



Using the code from "Performing XSLT Transforms on XML Data Stored in
SQL Server 2005" [1] I get an 'Invalid character in the given encoding'
error [2].

This error happens when there is a charcater like '§' in the XML.
Without 'strange' characters everything works fine.

I suppose this has something to do with the fact that XML data is
stored in UTF-16 in SQL XML data column and original XML data comes in
UTF-8 format but I don't know how to solve this error.

I have changed the encoding for the XmlTextWriter to UTF-8 and Unicode
with no succes.

Hopefully somebody can point me in the right direction.

Regards,

Emil Zegers

[1] http://blogs.msdn.com/mrorke/archive/2005/06/28/433471.aspx

[2]
A .NET Framework error occurred during execution of user defined
routine or aggregate 'ApplyXsltTransform':
System.Xml.XmlException: Invalid character in the given encoding. Line
1, position 9862.
System.Xml.XmlException:
at System.Xml.XmlTextReaderImpl.Throw(Exception e)
at System.Xml.XmlTextReaderImpl.Throw(String res, String arg)
at System.Xml.XmlTextReaderImpl.InvalidCharRecovery(Int32&
bytesCount, Int32& charsCount)
at System.Xml.XmlTextReaderImpl.GetChars(Int32 maxCharsCount)
at System.Xml.XmlTextReaderImpl.ReadData()
at System.Xml.XmlTextReaderImpl.ParseAttributeValueSlow(Int32
curPos, Char quoteChar, NodeData attr)
at System.Xml.XmlTextReaderImpl.ParseAttributes()
at System.Xml.XmlTextReaderImpl.ParseElement()
at System.Xml.XmlTextReaderImpl.ParseElementContent()
at System.Xml.XmlTextReaderImpl.Read()
at System.Xml.XmlTextReader.Read()
at System.Xml.XmlWriter.WriteNode(XmlReader reader, Boolean defattr)
at
System.Data.SqlTypes.SqlXml.CreateMemoryStreamFromXmlReader(XmlReader
reader)
at System.Data.SqlTypes.SqlXml..ctor(XmlReader value)
at XSLTTransform.Transform(SqlXml inputDataXML, SqlXml
inputTransformXML)

.



Relevant Pages

  • Re: iso-8859 xml read problem
    ... I have a url which I want to read some xml data from ... Changing the encoding is not an option!!! ... But i keep getting problems as the xmldocument or xmlreader cant seem to ... Stu ...
    (microsoft.public.dotnet.framework.compactframework)
  • Re: iso-8859 xml read problem
    ... > I have a url which I want to read some xml data from ... > Changing the encoding is not an option!!! ... This will give incorrect results if it actually is in iso-8859 format AND it ... uses special characters. ...
    (microsoft.public.dotnet.framework.compactframework)
  • iso-8859 xml read problem
    ... I have a url which I want to read some xml data from ... Changing the encoding is not an option!!! ... Stu ... Prev by Date: ...
    (microsoft.public.dotnet.framework.compactframework)
  • How can I change encoding in a VB.Net webservice?
    ... I have made a webservice which spits out some XML data. ... data gets the processing-instruction: ... Is it possible to change the encoding of this processing- ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Please help!!!! FTS confusing me
    ... thank you for the SQL Server 2000 version and OS platform ... lets troubleshoot this without reference to the 3rd Party XML ... linked to the IMAGE (blob) column that is holding your XML data. ... We have XML data stored in a table and are wanting to full text this ...
    (microsoft.public.sqlserver.fulltext)

Loading