XSL transformation on XML data in SQL 2005 causes 'invalid character' error
- From: "Emil" <e.zegers@xxxxxxxxxx>
- Date: 20 Nov 2006 08:25:37 -0800
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)
.
- Follow-Ups:
- Prev by Date: Re: Time Zone in xsd:date
- Next by Date: System.Data 1.1 / ADO.NET 1.1 and large datatypes introduced in SQL Server 2005
- Previous by thread: Re: Time Zone in xsd:date
- Next by thread: Re: XSL transformation on XML data in SQL 2005 causes 'invalid character' error
- Index(es):
Relevant Pages
|
Loading