SunQuest
           XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old February 19th, 2003, 12:00 PM
esosa esosa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Mexicali Mexico
Posts: 23 esosa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to esosa
ADO Saved objRS to XML CharSet Encoding Problem

I have a problem using the ADO Recordset's Save Method (Saving as XML), as this method can only (as far as I know) save the Recordset in the UTF-8 encoding charset.

I am using XML Islands to display and filter the resulting XML Document (applying some XSLT for the looks, sorting and filtering)

The problem comes when the Resulting XML file contains certain NON COMPLIANT Characters like the Ñ, á, í, ñ, characters that are iso-8859-1 charset compliant, the data island simply returns no results, even tough the xml file contains the results, but the thing is that the file contains the previously described characters in UTF-8 format, wich the MSXML Parser (on the Javascript side of this script) seems can not handle.

I need to find a workaround to solve this problem, I was thinking about making an ASP component to wich I could pass the recordset and the component would save to a file or to an object (as the Stream Object) the resulting XML (iso-8859-1 encoding), but if someone has a better approach I would really appreciate.

Here I post part of the code wich I am using for the XML transformation, is the ASP part, I need this transformation in order to use the resulting XML, because the save method of the recordset returns it in a propietary way.

Part of this code I took it from an article at
http://www.eggheadcafe.com/articles/20011108.asp

=========== My ASP Code =========
Set objRS = adocmd1.Execute
'=========== XML DOCS GENERATION ===========
Const adPersistXML = 1
Dim objXMLDOM
Set objXMLDOM = Server.CreateObject("MSXML2.DOMDocument.4.0")
Set ObjStream = Server.CreateObject("ADODB.Stream")
ObjStream.Open
ObjStream.Charset = "iso-8859-1"
'somewhere I read that if I pass the saved recordset to an stream object wich has the iso charset, the result would be encoded in iso, but this didn't work

objRS.save ObjStream, adPersistXML

objXMLDOM.load(ObjStream)

ObjStream.close
Set ObjStream = Nothing

'=========== Transformar el XML del SAVE a formato Comprensible en XSLT

Dim strCleanXML, objXMLDOM_XSLT

Set objXMLDOM_XSLT = CreateObject("MSXML2.DOMDocument.4.0")
'Set objXMLDOM_XSLT = CreateObject("MSXML2.DOMDocument.3.0")

'=========== Este es el XSLT de la transformación
objXMLDOM_XSLT.load(Server.MapPath("xml/xslt/RecordsetCleaner3.xsl"))

'=========== Este es el XSLT de la transformación
strCleanXML = objXMLDOM.transformNode(objXMLDOM_XSLT)
Set objXMLDOM = Nothing
Set objXMLDOM_XSLT = Nothing

The resulting strClean is the XML complete String, wich later I save to an XML document, for further reference in my xml data island.

I have read a lot of articles wich say this can be solved by putting another charset declaration in the xml file like this in the xml data island declaration in the html

<xml id="records" src="xml/usrfiles/1234.xml"></xml><?xml version="1.0" encoding="iso-8859-1"?>

I have also tried puting UTF-8 instead of the iso, but with no positive results.

Any help will be appreciated.

Reply With Quote
  #2  
Old February 19th, 2003, 06:20 PM
esosa esosa is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Dec 2002
Location: Mexicali Mexico
Posts: 23 esosa User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Send a message via ICQ to esosa
I already solve it, it was all in the encoding declaration, at both, the final xml, and the XSLT

here I post the fix, and the code
Code:
Set objRS = adocmd1.Execute

Const adPersistXML = 1
Dim objXMLDOM

Set objXMLDOM = Server.CreateObject("MSXML2.DOMDocument.4.0")
objRS.save objXMLDOM, adPersistXML

Dim strCleanXML, objXMLDOM_XSLT

Set objXMLDOM_XSLT = CreateObject("MSXML2.DOMDocument.4.0")

objXMLDOM_XSLT.load(Server.MapPath("xml/xslt/RecordsetCleaner3.xsl"))

strCleanXML = objXMLDOM.transformNode(objXMLDOM_XSLT)

'this line did the trick

strCleanXML = "<?xml version=""1.0"" encoding=""iso-8859-1""?>" & strCleanXML

Set objXMLDOM = Nothing
Set objXMLDOM_XSLT = Nothing

======================

and this here bellow are the first lines of the XSLT
in wich I declare the charset in wich the recordset was delivered, I think this also helped, since the save method of the ADO recordset object always gives the UTF-8 encoding, then I put that encoding in the XSLT

as this


Code:
 
<?xml version="1.0" encoding="UTF-8"?>
<!-- RecordsetCleaner3.xsl -->

<xsl:stylesheet version="1.0"

Hope this helps someone

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > ADO Saved objRS to XML CharSet Encoding Problem


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway