I
Iain Toft
I'm having problems displaying the ? euro dollar sign in XML produced
from an XSL transform.
SQL Server 2000 is used to produce XML (SELECT .. FOR XML) from a
database table containing data. The euro dollar displays fine in the
database table and in the SQL Server generated XML(snippet below) but
not in the transformed XML. In fact in this post it will probably
appear as a question mark anyway!
<transporttype>Vehicle types include Suzuki Samurai Jeep, closed
air-con cars, Jimny Jeeps with A/C, and Vitara convertible Jeeps with
A/C. Rates from ?70 to ?85 per day. The above rate includes 3rd party
insurance, unlimited kilometres and delivery to
hotels.</transporttype>
Having done the transform in ASP (below) the output XML file has the
'?' instead of the intended '?'. Having fiddled with encoding types
set in ASP code (see below) I coaxed a '¤' out of it!
ASP scripts are used to request the XML from database (stored
procedure) then transform it using XSLT:
Set objConn = CreateObject("ADODB.Connection")
Set objCMD = CreateObject("ADODB.Command")
set objDOM = CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
set objDOMOutput = CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
set objXSL = CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
objDOM.async = false
objXSL.async = false
.... some setting up db connections and SQL strings for objCMD here
objCMD.Properties("Output Stream") = objDOM
objCMD.Execute , , 1024
Dim objPI
set objPI = objDom.createProcessingInstruction("xml", "version='1.0'
encoding='UTF-8'")
objDom.insertBefore objPI, objDom.childNodes(0)
objXSL.load(arrStyleSheet(i))
objDOM.transformNodeToObject objXSL, objDOMOutput
the transformed xml is then passed to the function:
asCreateFile(lcase(strFilePath), lcase(strFileName),
asDOM2XML(objDOMOutput))
function asCreateFile(path, name, content)
Dim objStream
asCreateFile = false
if asCreatePath(path) then
set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 2
objStream.Charset = "iso-8859-1"
objStream.Open
objStream.writetext(content)
objStream.SaveToFile path & name, 2
objStream.Close
Set objStream = nothing
asCreateFile = true
end if
end function
Not entirely sure what asDOM2XML function does but here it is for all
those interested:
function asDOM2XML(objDOM)
'/* used to be: objDOMOutput.firstChild.xml &
replace(objDOMOutput.childNodes(1).xml,chr(13)+chr(10),"<br/>")
if objDOM.childNodes.length > 1 then
asDOM2XML = objDOM.firstChild.xml &
replace(objDOM.lastChild.xml,chr(13)+chr(10),"<br/>")
else
'asDOM2XML = replace(objDOM.firstChild.xml,chr(13)+chr(10),"<br/>")
asDOM2XML = objDOM.xml
end if
end function
from an XSL transform.
SQL Server 2000 is used to produce XML (SELECT .. FOR XML) from a
database table containing data. The euro dollar displays fine in the
database table and in the SQL Server generated XML(snippet below) but
not in the transformed XML. In fact in this post it will probably
appear as a question mark anyway!
<transporttype>Vehicle types include Suzuki Samurai Jeep, closed
air-con cars, Jimny Jeeps with A/C, and Vitara convertible Jeeps with
A/C. Rates from ?70 to ?85 per day. The above rate includes 3rd party
insurance, unlimited kilometres and delivery to
hotels.</transporttype>
Having done the transform in ASP (below) the output XML file has the
'?' instead of the intended '?'. Having fiddled with encoding types
set in ASP code (see below) I coaxed a '¤' out of it!
ASP scripts are used to request the XML from database (stored
procedure) then transform it using XSLT:
Set objConn = CreateObject("ADODB.Connection")
Set objCMD = CreateObject("ADODB.Command")
set objDOM = CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
set objDOMOutput = CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
set objXSL = CreateObject("Msxml2.FreeThreadedDOMDocument.3.0")
objDOM.async = false
objXSL.async = false
.... some setting up db connections and SQL strings for objCMD here
objCMD.Properties("Output Stream") = objDOM
objCMD.Execute , , 1024
Dim objPI
set objPI = objDom.createProcessingInstruction("xml", "version='1.0'
encoding='UTF-8'")
objDom.insertBefore objPI, objDom.childNodes(0)
objXSL.load(arrStyleSheet(i))
objDOM.transformNodeToObject objXSL, objDOMOutput
the transformed xml is then passed to the function:
asCreateFile(lcase(strFilePath), lcase(strFileName),
asDOM2XML(objDOMOutput))
function asCreateFile(path, name, content)
Dim objStream
asCreateFile = false
if asCreatePath(path) then
set objStream = Server.CreateObject("ADODB.Stream")
objStream.Type = 2
objStream.Charset = "iso-8859-1"
objStream.Open
objStream.writetext(content)
objStream.SaveToFile path & name, 2
objStream.Close
Set objStream = nothing
asCreateFile = true
end if
end function
Not entirely sure what asDOM2XML function does but here it is for all
those interested:
function asDOM2XML(objDOM)
'/* used to be: objDOMOutput.firstChild.xml &
replace(objDOMOutput.childNodes(1).xml,chr(13)+chr(10),"<br/>")
if objDOM.childNodes.length > 1 then
asDOM2XML = objDOM.firstChild.xml &
replace(objDOM.lastChild.xml,chr(13)+chr(10),"<br/>")
else
'asDOM2XML = replace(objDOM.firstChild.xml,chr(13)+chr(10),"<br/>")
asDOM2XML = objDOM.xml
end if
end function