Re: XSL transformation on XML data in SQL 2005 causes 'invalid character' error
- From: "Han" <hp4444@xxxxxxxxxxxxxxxx>
- Date: Fri, 24 Nov 2006 14:13:19 +0900
Hello
Change the XML stream into unicode string BEFORE feed the data to DB.
param.value=xmltextreader.readouterxml();
I hope I understand your question properly.
"Emil" <e.zegers@xxxxxxxxxx> wrote in message
news:1164039937.681642.3670@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
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)
.
- References:
- Prev by Date: SQLXML encoding setting
- Next by Date: Re: XQuery path to root
- Previous by thread: XSL transformation on XML data in SQL 2005 causes 'invalid character' error
- Next by thread: System.Data 1.1 / ADO.NET 1.1 and large datatypes introduced in SQL Server 2005
- Index(es):
Relevant Pages
|
Loading