Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Returning the data encoded
Message
De
21/05/2003 00:22:09
 
 
À
Tous
Information générale
Forum:
ASP.NET
Catégorie:
Web Services
Titre:
Returning the data encoded
Divers
Thread ID:
00790893
Message ID:
00790893
Vues:
43
From a VFP Web Service, I was calling this function to encode the data so all French characters were submitted ok and ready to be viewed in the browser:
* Rebuild a XML document assuring a specific character encoding
*
* expC1 Target encoding - such as "utf-8" or "iso-8859-1"
* expC2 XML document in string or object form
FUNCTION ReEncodeXML
PARAMETERS tcTargetEncoding,tcXML
LOCAL lcCr,lcResultFile,lcReencoder,loXML,loStylesheet,loResultXML,lcXML
lcCr=CHR(13)+CHR(10)
lcReencoder='<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">'+lcCr+;
 '<xsl:output method="xml" encoding="'+LOWER(tcTargetEncoding)+'" omit-xml-declaration="no" indent="yes"/> '+lcCr+;
 '<xsl:template match="/ | @* | node()">'+lcCr+;
 '<xsl:copy>'+lcCr+;
 '<xsl:apply-templates select="@* | node()"/>'+lcCr+;
 '</xsl:copy>'+lcCr+;
 '</xsl:template>'+lcCr+;
 '</xsl:stylesheet>'+lcCr

* Create an XML object from the string
loXML=CREATEOBJECT('MSXML2.DOMDocument.3.0')
loXML.Async=.F.
loXML.LoadXML(tcXML)

* Create an XML object for the stylesheet
loStyleSheet=CREATEOBJECT('MSXML2.DOMDocument.3.0')
loStyleSheet.Async=.F.
loStyleSheet.LoadXML(lcReencoder)

* Create the reencoded object
loResultXML=CREATEOBJECT('MSXML2.DOMDocument.3.0')
loResultXML.Async=.F.
loResultXML.ValidateOnParse=.T.

* Execute the transformation and store the transformation in the new object
loXML.TransformNodeToObject(loStyleSheet,loResultXML)

* Save the result to a temporary file and read it back as a string
lcResultFile=ADDBS(SYS(2023))+SYS(2015)+'.xml'
loResultXML.Save(lcResultFile)
lcXML=FILETOSTR(lcResultFile)
ERASE (lcResultFile)

RETURN lcXML
Now, that the Web Service has been converted to .NET, do I really need to do the same or there could be this magic function I could call? :)
Michel Fournier
Level Extreme Inc.
Designer, architect, owner of the Level Extreme Platform
Subscribe to the site at https://www.levelextreme.com/Home/DataEntry?Activator=55&NoStore=303
Subscription benefits https://www.levelextreme.com/Home/ViewPage?Activator=7&ID=52
Répondre
Fil
Voir

Click here to load this message in the networking platform