Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. XML / XSL
  4. XML + XSL in a Client Browser

XML + XSL in a Client Browser

Scheduled Pinned Locked Moved XML / XSL
xmlcsharpasp-netsysadminbeta-testing
4 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Lea Hayes
    wrote on last edited by
    #1

    Hi guys, Usually I use XSL to transform XML at the server-side with ASP.NET. I have recently found out that it is possible to specify a stylesheet at the top of an XML file. The web browser then uses the XSL document to render the XML file. I came across several websites which say that there is lack of browser support, but they were quite old. I have tested a simple scenario in IE7, IE8 BETA, Chrome, FF3, and Safari and it seems to work wonders. So I didn't know whether there were any more subtle issues, or compatibility problems. Are there any issues with this approach? Ideally I wanted to have the client browser do the transforms to ease the load at the server-side. Many thanks, Lea Hayes

    L S 2 Replies Last reply
    0
    • L Lea Hayes

      Hi guys, Usually I use XSL to transform XML at the server-side with ASP.NET. I have recently found out that it is possible to specify a stylesheet at the top of an XML file. The web browser then uses the XSL document to render the XML file. I came across several websites which say that there is lack of browser support, but they were quite old. I have tested a simple scenario in IE7, IE8 BETA, Chrome, FF3, and Safari and it seems to work wonders. So I didn't know whether there were any more subtle issues, or compatibility problems. Are there any issues with this approach? Ideally I wanted to have the client browser do the transforms to ease the load at the server-side. Many thanks, Lea Hayes

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      lhayes00 wrote:

      So I didn't know whether there were any more subtle issues, or compatibility problems.

      There certainly can be, I imagine. This is awkward since I detest assumptions, however given the history of browser compatibility it's likely a safe one.

      lhayes00 wrote:

      Are there any issues with this approach?

      Obviously, the more basic your XML-XSLT is the less likely any problems will surface. Conversely.... well I think you get the idea, yes?

      led mike

      1 Reply Last reply
      0
      • L Lea Hayes

        Hi guys, Usually I use XSL to transform XML at the server-side with ASP.NET. I have recently found out that it is possible to specify a stylesheet at the top of an XML file. The web browser then uses the XSL document to render the XML file. I came across several websites which say that there is lack of browser support, but they were quite old. I have tested a simple scenario in IE7, IE8 BETA, Chrome, FF3, and Safari and it seems to work wonders. So I didn't know whether there were any more subtle issues, or compatibility problems. Are there any issues with this approach? Ideally I wanted to have the client browser do the transforms to ease the load at the server-side. Many thanks, Lea Hayes

        S Offline
        S Offline
        Steve Marsh
        wrote on last edited by
        #3

        I'm not sure which browsers other than IE support embedded XSLT documents, meaning they automatically do the transformation. However you can do the transformation using javascript and write out the result using the .innerHTML property. This is especially useful when creating Ajax style interfaces. The code looks something like this:

        var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
        xmlDoc.async = false;
        xmlDoc.load("doc.xml")

        var xslDoc = new ActiveXObject("Msxml2.DOMDocument");
        xslDoc.async = false;
        xslDoc.load(Server.MapPath("doc.xsl"));

        myDiv.innerHTML = xmlDoc.transformNode(xslDoc);

        For cross-browser support you will need to modify the line of code where you create the Xml document because different browsers handle it differently.

        L 1 Reply Last reply
        0
        • S Steve Marsh

          I'm not sure which browsers other than IE support embedded XSLT documents, meaning they automatically do the transformation. However you can do the transformation using javascript and write out the result using the .innerHTML property. This is especially useful when creating Ajax style interfaces. The code looks something like this:

          var xmlDoc = new ActiveXObject("Msxml2.DOMDocument");
          xmlDoc.async = false;
          xmlDoc.load("doc.xml")

          var xslDoc = new ActiveXObject("Msxml2.DOMDocument");
          xslDoc.async = false;
          xslDoc.load(Server.MapPath("doc.xsl"));

          myDiv.innerHTML = xmlDoc.transformNode(xslDoc);

          For cross-browser support you will need to modify the line of code where you create the Xml document because different browsers handle it differently.

          L Offline
          L Offline
          Lea Hayes
          wrote on last edited by
          #4

          Hi, That's fantastic! I am working on Ajax stuff at the moment, I didn't realize you could do XSL transforms with JavaScript. Thanks for that! :-D Lea Hayes

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups