Euro Dollar Frustration - XSLT, ASP

Discussion in 'XML' started by Iain Toft, Jul 17, 2003.

  1. Iain Toft

    Iain Toft Guest

    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
     
    Iain Toft, Jul 17, 2003
    #1
    1. Advertising

  2. In article <>,
    Iain Toft <> wrote:
    >I'm having problems displaying the ? euro dollar sign in XML produced
    >from an XSL transform.


    I don't know anything about SQL or ASP, but I notice you have

    > objStream.Charset = "iso-8859-1"


    The Euro symbol does not exist in iso-8859-1. Try using iso-8859-15
    instead.

    -- Richard
    --
    Spam filter: to mail me from a .com/.net site, put my surname in the headers.

    FreeBSD rules!
     
    Richard Tobin, Jul 17, 2003
    #2
    1. Advertising

  3. Iain Toft

    Chris Lovett Guest

    See http://msdn.microsoft.com/library/en-us/dnxml/html/xmlencodings.asp

    The problem is most likely in the asCreateFile function which is saving the
    DOM document to a file via the SaveToFile method on an ADODB.Stream object
    specifying the an encoding that cannot handle the Euro character. This is
    silly. You can easily save a DOM document to file using the DOM object's
    own save method, and it is more likely to encode the document correctly that
    way as follows:

    objDOMOutput.save(path);

    It appears the author of this code was concerned about converting the
    newlines in the xml markup to <br/> tags, perhaps in an attempt at having
    the XML formatted properly in the browser.

    Another way to achieve this is to wrap the XML output in <pre> tags. Or if
    you really still need to call asDOM2XML then you could "reload" this string
    into the DOM object so you can use the DOM object to save the xml to disk
    properly.


    "Iain Toft" <> wrote in message
    news:...
    > 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
     
    Chris Lovett, Jul 20, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Javier Sandobal

    The Power Of One Dollar...

    Javier Sandobal, Dec 10, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    739
    Javier Sandobal
    Dec 10, 2004
  2. Norman Yuan
    Replies:
    0
    Views:
    865
    Norman Yuan
    Dec 8, 2005
  3. zzyzx

    Division of Dollar value

    zzyzx, Jul 22, 2004, in forum: Java
    Replies:
    12
    Views:
    1,424
    Michael Borgwardt
    Jul 23, 2004
  4. Iain Toft
    Replies:
    4
    Views:
    1,710
    Mark Preston
    Jul 20, 2003
  5. Badbetty

    XSL, XSLT frustration

    Badbetty, Aug 12, 2008, in forum: XML
    Replies:
    3
    Views:
    380
    Ken Starks
    Aug 17, 2008
Loading...

Share This Page