“Fixing” MSXML encodings in XSL transformations

In one of the projects that I’m working in we had to do some server-side transforming using MSXML. Everything went well until we transformed some pages using German umlauts. The encoding in the XML file was correctly set but the result was completely ignoring the umlauts, replacing them with the question mark sign.

The code was using the transformNode() method. In this case MSXML is always using internally a string format called BSTR which is UTF-16 encoded data. So whatever encoding is set it will be ignored.
The solution is to use transformNodeToObject() method which is keeping the encoding settings.

You can download the complete Notes Dabatase from here: MSXMLEnc.nsf

Sub transform() On Error Goto errorHandler Const urlBase = “http://localhost/MSXMLEnc.nsf” Dim xmlDoc As Variant, xslDoc As Variant Dim xmlDocURL As String, xslDocURL As String xmlDocURL = urlBase + “/article.xml” xslDocURL = urlBase + “/article.xsl” ‘ initthe XML and XSL Set xmlDoc = CreateObject(“Msxml2.DOMDocument.3.0″) xmlDoc.async = False Set xslDoc = CreateObject(“Msxml2.DOMDocument.3.0″) xslDoc.async = False ‘ load the XML and XSL xmlDoc.load( xmlDocURL ) xslDoc.load( xslDocURL ) ‘ we need to do the transformation using the transformNodeToObject() ‘method and a stream implementing the IStream interface. ‘ If not the character encoding is not kept Dim adoStream As Variant Set adoStream = CreateObject(“ADODB.Stream”) adoStream.Open adoStream.Type = 2 ‘2 -> adTypeText -> Text data adoStream.Charset = “ISO-8859-15″ ‘transform and store the result in stream Call xmlDoc.transformNodeToObject(xslDoc, adoStream) ‘place in a file and attach it Dim strDocUNID As String strDocUNID = storeHTML( adoStream ) adoStream.Close Set adoStream = Nothing Set xmlDoc = Nothing Set xslDoc = Nothing Print “[” + urlBase “/0/” + strDocUnid + “/$file/article.html]” Exit Sub errorHandler: Print “Error #”+Cstr(Err)+” <”+Error$+“>in MSXML Transformation on line “ +Cstr(Erl) Exit Sub End Sub
This LotusScript was converted to HTML using the ls2html routine,
provided by Julian Robichaux at nsftools.com.


Formula language - @Eval

Florin a observat ca activitatea mea pe site este sporadica, asa ca s-a gandit sa-mi dea un pic de ajutor:

Salut! Am hotarat sa aduc si eu ceva comunitatii Lotus Notes din România si sa ofer cateva idei care consider ca sunt interesante din punctul de vedere al programatorului.

O sa incep cu Formula Language.

Formula Language fiind un „scripting language“ greu de structurat este de foarte multe ori respins de programatori si inlocuit cu lotus script. Totusi consider ca formula language joaca un rol foarte important in dezvoltarea bazelor Lotus Notes asa ca am ales sa incep cu functia @Eval.

Conform help, functia @Eval compileaza si ruleaza fiecare element dintr-un text ca o @formula.

Unul din cazurile in care @Eval poate fi folosit este in momentul in care codul pe care il scriem este necesar in mai multe locuri in aplicatie si teoretic am avea nevoie de o functie/procedura.

De exemplu sa consideram ca avem o forma care contine mai multe butoane care afiseaza intr-un @PickList view-ul „Config“ si intoarce valoarea dintr-o anumita coloana intr-un anumit camp.

O solutie „parametrizata“ a acestei probleme poate fi implementata folosind un camp computed for display EvalPickList in care scriem ca si text formula pe care dorim sa o evaluam:

evaluate field

In buton nu ne mai ramane decat sa initializam „argumentele“ si sa evaluam campul EvalPickList:

evaluate button


Salveaza local, in format .chm si .hxs, documentatia MSDN

Astazi am rasfoit un pic documentatia MSXML disponibila pe siteul MSDN si mi-am dorit o versiune offline a documentelor, dar nu am reusit sa gasesc nimic.

Chiar inaine sa renunt am zarit un program care permite salvarea in format .chm sau .hxs. a documentatiei MSDN.

Programul se numeste Package This si il gasiti aici www.codeplex.com.

Pentru a funtiona aveti nevoie de: framework-ul .NET 2.0, .hxs SDK (MSHelp 2.0) sau .chm SDK (HTML Help) in functie de formatul in care doriti sa salvati documentatia.

Programul lucreaza simplu:
1. selectezi punctele/documentele de interes
2. salvezi totul in formatul dorit

Package This


Pagini
Calendar
April 2007
M T W T F S S
« Mar   May »
 1
2345678
9101112131415
16171819202122
23242526272829
30  
Momentan răsfoiţi arhiva cotârlea.ro pentru luna April, 2007.
Categorii
Arhivă