Im experiencing strange xml transform problems

Discussion in 'ASP General' started by frustratedcoder, Jun 28, 2005.

  1. When I call the transformnode on my xml object like this:
    response.write xmlobj.transformnode(xsl) I get the actual xsl sent to
    the browser.

    Here is my code:

    <%@LANGUAGE="VBSCRIPT"%>

    <%
    Dim xmlhttp, xsldoc, xmldoc
    set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
    xmlhttp.open "GET", "http://some-server.com/xmlfile", false
    xmlhttp.send

    set xsldoc = Server.CreateObject("Microsoft.XMLDOM")
    xsldoc.async = false
    xsldoc.load(Server.MapPath("stylesheet.xsl"))

    set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
    xmldoc.async = false
    xmldoc.loadXML(xmlhttp.responseText)

    response.write xmldoc.transformNode(xsldoc)
    %>

    No error message is sent back from the object, I just get the xsl if I
    view the source.

    I have tried to call a newer xml object but this appears to be the only
    accessible to me on the server.
    frustratedcoder, Jun 28, 2005
    #1
    1. Advertising

  2. frustratedcoder wrote:


    > Dim xmlhttp, xsldoc, xmldoc
    > set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
    > xmlhttp.open "GET", "http://some-server.com/xmlfile", false
    > xmlhttp.send
    >
    > set xsldoc = Server.CreateObject("Microsoft.XMLDOM")
    > xsldoc.async = false
    > xsldoc.load(Server.MapPath("stylesheet.xsl"))
    >
    > set xmldoc = Server.CreateObject("Microsoft.XMLDOM")
    > xmldoc.async = false
    > xmldoc.loadXML(xmlhttp.responseText)


    Make those three lines
    Set xmldoc = xmlhttp.responseXML

    > response.write xmldoc.transformNode(xsldoc)


    Use
    xmldoc.transformNodeToObject(xsldoc, Response)
    instead.
    Of course depending on what kind of content your XSL stylesheet creates
    you need to set
    Response.ContentType
    appropriately.

    > No error message is sent back from the object, I just get the xsl if I
    > view the source.


    There are several things that can go wrong, check
    xmlhttp.status
    to be 200, check whether xsldoc.load return true so that you know that
    the stylesheet is well-formed.

    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jun 28, 2005
    #2
    1. Advertising

  3. Thank you for the reply. I changed my code into:
    Dim xmlhttp, xsldoc, xmldoc
    set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")
    xmlhttp.open "GET", "http://www.somesite.com/xml", false
    xmlhttp.send

    set xsldoc = Server.CreateObject("Microsoft.XMLDOM")
    xsldoc.async = false
    xsldoc.load(Server.MapPath("stylesheet.xsl"))

    set xmldoc = xmlhttp.responseXML

    response.ContentType = "text/html"

    xmldoc.transformNodeToObject xsldoc, Response

    The xsl's output method is set to html, but the result is the same: I
    get the xslt when I check the source.
    frustratedcoder, Jun 29, 2005
    #3
  4. frustratedcoder wrote:
    > Thank you for the reply. I changed my code into:
    > Dim xmlhttp, xsldoc, xmldoc
    > set xmlhttp = Server.CreateObject("Microsoft.XMLHTTP")



    You should use the "Server" version of the XMLHTTP object. Also, I usually
    am a little bit more explicit in my server-side code:

    set xmlhttp = Server.CreateObject("msxml2.ServerXMLHTTP")


    > xmlhttp.open "GET", "http://www.somesite.com/xml", false
    > xmlhttp.send
    >


    Don't create and load your "xsl" document until you have verified that you
    have received something from your xmlhttp request. I am going to rearrange
    things now

    >
    > set xmldoc = xmlhttp.responseXML


    First debugging step:

    response.ContentType = "text/xml"
    xmldoc.save Response
    Response.End

    If all looks well when you run the page, comment out the above lines. I
    would still add something like:

    If len(xmldoc.xml) > 0 then

    > set xsldoc = Server.CreateObject("Microsoft.XMLDOM")


    set xsldoc = Server.CreateObject("msxml2.DomDocument")

    > xsldoc.async = false
    > xsldoc.load(Server.MapPath("stylesheet.xsl"))
    >
    > response.ContentType = "text/html"
    >
    > xmldoc.transformNodeToObject xsldoc, Response


    else
    response.write "No xml was returned"
    end if

    >
    > The xsl's output method is set to html, but the result is the same: I
    > get the xslt when I check the source.


    Try "text/xml"

    Also, if you have "on error resume next" anywhere, comment it out.

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"
    Bob Barrows [MVP], Jun 29, 2005
    #4
  5. Thank you for the reply.

    The msxml2.ServerXMLHTTP is not available on the server, only xmlhttp
    and xmldom are available.
    frustratedcoder, Jun 29, 2005
    #5
  6. frustratedcoder wrote:
    > Thank you for the reply.
    >
    > The msxml2.ServerXMLHTTP is not available on the server, only xmlhttp
    > and xmldom are available.


    Sounds as if that's the issue then. Can they install the latest version of
    the MSXML Parser on the server?

    In the meantime, have you tried my other debugging suggestions? What result
    did you get from them?

    Bob Barrows
    --
    Microsoft MVP -- ASP/ASP.NET
    Please reply to the newsgroup. The email account listed in my From
    header is my spam trap, so I don't check it very often. You will get a
    quicker response by posting to the newsgroup.
    Bob Barrows [MVP], Jun 29, 2005
    #6
  7. frustratedcoder wrote:

    > The msxml2.ServerXMLHTTP is not available on the server, only xmlhttp
    > and xmldom are available.


    What server is that? Old versions of MSXML as installed on Win 98 or
    2000 do not support XSLT 1.0 at all, you need to have at least MSXML 3
    (which is installed by IE 6) to do XSLT 1.0 transformations.



    --

    Martin Honnen --- MVP XML
    http://JavaScript.FAQTs.com/
    Martin Honnen, Jun 29, 2005
    #7
  8. I called the host provider yesterday and they confirmed that this was
    an error and that they would upgrade.

    Thank you all for your help.
    frustratedcoder, Jun 30, 2005
    #8
    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. KathyB
    Replies:
    0
    Views:
    1,011
    KathyB
    Jun 25, 2003
  2. =?Utf-8?B?Q2hyaXM=?=
    Replies:
    1
    Views:
    326
    Karl Seguin
    Jan 7, 2005
  3. Replies:
    1
    Views:
    741
    Esmond Pitt
    Mar 27, 2005
  4. Duane Morin
    Replies:
    3
    Views:
    628
    Marten Gaans
    Jan 26, 2004
  5. N. Demos
    Replies:
    2
    Views:
    351
    N. Demos
    May 13, 2005
Loading...

Share This Page