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. load xml+xsl in html

load xml+xsl in html

Scheduled Pinned Locked Moved XML / XSL
xmlhtmltoolstutorialquestion
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.
  • U Offline
    U Offline
    User 4657403
    wrote on last edited by
    #1

    i have loaded xml+xsl in html. but it only works for simple xml and xsl.when i have a large xml and slightly cmplex xsl and have dtd the code dosen't work. here is the code for loading:: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { ///////////////LOAD XML & XSL///////////////// xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("book2006.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); } } can anyone send me the code works for all xml and xsl pls?

    L A 2 Replies Last reply
    0
    • U User 4657403

      i have loaded xml+xsl in html. but it only works for simple xml and xsl.when i have a large xml and slightly cmplex xsl and have dtd the code dosen't work. here is the code for loading:: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { ///////////////LOAD XML & XSL///////////////// xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("book2006.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); } } can anyone send me the code works for all xml and xsl pls?

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

      Member 4660724 wrote:

      the code dosen't work.

      And you think we know what that means? Good luck

      led mike

      1 Reply Last reply
      0
      • U User 4657403

        i have loaded xml+xsl in html. but it only works for simple xml and xsl.when i have a large xml and slightly cmplex xsl and have dtd the code dosen't work. here is the code for loading:: function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { ///////////////LOAD XML & XSL///////////////// xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("book2006.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); } } can anyone send me the code works for all xml and xsl pls?

        A Offline
        A Offline
        Aurelius1664
        wrote on last edited by
        #3

        Do the xml namespaces in the more complex xml and those in the more complex xslt match? This often happens when moving from a test document to a real live one. We can't see the problem unless you want to put up an example of the simple xml/xslt and then the more complex failing ones.

        http://www.effinities.com

        U 1 Reply Last reply
        0
        • A Aurelius1664

          Do the xml namespaces in the more complex xml and those in the more complex xslt match? This often happens when moving from a test document to a real live one. We can't see the problem unless you want to put up an example of the simple xml/xslt and then the more complex failing ones.

          http://www.effinities.com

          U Offline
          U Offline
          User 4657403
          wrote on last edited by
          #4

          Hi, the problem of loading xml+xsl is solved for mozilla.the problem was i ddin't know mozilla doesn't support external dtd.it works fine for internal dtd.But IE cannot load either external or internal.i used several alerts in several position.all are showed in output.but the transformed xml page does not show. function loadXMLDoc(fname) { var xmlDoc; // code for IE if (window.ActiveXObject) { xmlDoc=new ActiveXObject("Microsoft.XMLDOM"); alert("LoadXML"); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xmlDoc=document.implementation.createDocument("","",null); } else { alert('Your browser cannot handle this script'); } xmlDoc.async=false; xmlDoc.load(fname); return(xmlDoc); } function displayResult() { xml=loadXMLDoc("Book2006_Overview.xml"); xsl=loadXMLDoc("Book2006_manee.xsl"); // code for IE if (window.ActiveXObject) { ex=xml.transformNode(xsl); document.getElementById("example").innerHTML=ex; alert("after innerHTML"); alert(ex); } // code for Mozilla, Firefox, Opera, etc. else if (document.implementation && document.implementation.createDocument) { xsltProcessor=new XSLTProcessor(); xsltProcessor.importStylesheet(xsl); resultDocument = xsltProcessor.transformToFragment(xml,document); document.getElementById("example").appendChild(resultDocument); } }

          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