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. XSL import another XSL on Client-Side.

XSL import another XSL on Client-Side.

Scheduled Pinned Locked Moved XML / XSL
xmlquestioncsharpjavascriptregex
4 Posts 2 Posters 3 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.
  • Y Offline
    Y Offline
    yeob
    wrote on last edited by
    #1

    I try XSL Transfrom on client-side using javascript. My XSL file has a import tag in itself, but it couln't find the another XSL file. I have to excute this transform on Client-Side for some reason. How can I put the import href content Here goes my test code. this page written with .NET Javascript code on the webpage. function Transform() { var xsl = new ActiveXObject("MSXML.DOMDocument"); var xml = new ActiveXObject("MSXML.DOMDocument"); xsl.async = false; xsl.load(dataXmlPath); xsl.async = false; xsl.load(styleXslPath); var data = xml.transformNode(xsl); } number.xml (XML Data file)----------------------- <?xml version='1.0'?> <data> <circle> <radius>12</radius> </circle> <circle> <radius>37.5</radius> </circle> </data> calc.xsl (XSL Style file)------------------------ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:include href="calc2.xsl"/> </xsl:stylesheet> calc2.xsl (XSL import file)------------------------ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="data"> <circles> <xsl:for-each select="circle"> <circle> <xsl:copy-of select="node()"/> <circumference> <xsl:value-of select="radius"/> </circumference> </circle> </xsl:for-each> </circles> </xsl:template> </xsl:stylesheet>

    D 1 Reply Last reply
    0
    • Y yeob

      I try XSL Transfrom on client-side using javascript. My XSL file has a import tag in itself, but it couln't find the another XSL file. I have to excute this transform on Client-Side for some reason. How can I put the import href content Here goes my test code. this page written with .NET Javascript code on the webpage. function Transform() { var xsl = new ActiveXObject("MSXML.DOMDocument"); var xml = new ActiveXObject("MSXML.DOMDocument"); xsl.async = false; xsl.load(dataXmlPath); xsl.async = false; xsl.load(styleXslPath); var data = xml.transformNode(xsl); } number.xml (XML Data file)----------------------- <?xml version='1.0'?> <data> <circle> <radius>12</radius> </circle> <circle> <radius>37.5</radius> </circle> </data> calc.xsl (XSL Style file)------------------------ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:include href="calc2.xsl"/> </xsl:stylesheet> calc2.xsl (XSL import file)------------------------ <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:template match="data"> <circles> <xsl:for-each select="circle"> <circle> <xsl:copy-of select="node()"/> <circumference> <xsl:value-of select="radius"/> </circumference> </circle> </xsl:for-each> </circles> </xsl:template> </xsl:stylesheet>

      D Offline
      D Offline
      daveyerwin
      wrote on last edited by
      #2

      <script>    function Transform() {          var xsl = new ActiveXObject("MSXML.DOMDocument");          var xml = new ActiveXObject("MSXML.DOMDocument");          xml.async = false;          xml.load("number.xml");          xsl.async = false;          xsl.load("calc.xsl");          return xml.transformNode(xsl);          }    alert(Transform()); </script>

      Y 1 Reply Last reply
      0
      • D daveyerwin

        <script>    function Transform() {          var xsl = new ActiveXObject("MSXML.DOMDocument");          var xml = new ActiveXObject("MSXML.DOMDocument");          xml.async = false;          xml.load("number.xml");          xsl.async = false;          xsl.load("calc.xsl");          return xml.transformNode(xsl);          }    alert(Transform()); </script>

        Y Offline
        Y Offline
        yeob
        wrote on last edited by
        #3

        yes. it works. thank you. actually i tested with below script function in order to get a XML Object. function loadXMLDoc(filepath) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",filepath,false); xhttp.send(""); return xhttp.responseXML; } I thought it's the same but it wasn't.. var xsl = new ActiveXObject("MSXML.DOMDocument"); xsl.async = false; xsl.load("calc.xsl"); this works fine.

        D 1 Reply Last reply
        0
        • Y yeob

          yes. it works. thank you. actually i tested with below script function in order to get a XML Object. function loadXMLDoc(filepath) { if (window.XMLHttpRequest) { xhttp=new XMLHttpRequest(); } else { xhttp=new ActiveXObject("Microsoft.XMLHTTP"); } xhttp.open("GET",filepath,false); xhttp.send(""); return xhttp.responseXML; } I thought it's the same but it wasn't.. var xsl = new ActiveXObject("MSXML.DOMDocument"); xsl.async = false; xsl.load("calc.xsl"); this works fine.

          D Offline
          D Offline
          daveyerwin
          wrote on last edited by
          #4

          I'm glad I could help.

          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