[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Dynamic processing of xml file using xsl and java

Subject: Re: Dynamic processing of xml file using xsl and javascript
From: Geert Josten <Geert.Josten@xxxxxxxxxxx>
Date: Fri, 29 Oct 2004 21:41:07 +0200
getelementbyid java
Hi,

Combining the attempt of Matthew and Anton, I come to the following, which is nearly there to
support MS IE as well (if anyone would want that).

Note that the transformNodeToObject for iebrowser does not seem to work, but I'm not familiar enough
to get it working quickly. Anyone?

<script type="text/javascript" language="JavaScript">
   var iebrowser = false;
   var nsbrowser = false;

   if (document.implementation && document.implementation.createDocument) {
     nsbrowser = true;
   } else if (window.ActiveXObject) {
     iebrowser = true
   } else {
     alert('Your browser can\'t handle this script');
   }

var processor = createProcessor();

   var dataXML = createDocument();
   if (dataXML) {
     dataXML.load("data.xml");
   }

   var dataXSL = createDocument();
   if (dataXSL) {
     if (nsbrowser) {
       dataXSL.addEventListener("load", onload, false);
     }
     dataXSL.load("data.xsl");
   }

   function createDocument() {
     var doc = null;
     if (nsbrowser) {
       doc = document.implementation.createDocument("", "", null);
     } else if (iebrowser) {
       doc = new ActiveXObject("Microsoft.XMLDOM");
     }
     return doc;
   }

   function createProcessor() {
     var proc = null;
     if (nsbrowser) {
       proc = new XSLTProcessor();
     }
     return proc;
   }

   function onload()
   {
     if (nsbrowser) {
       processor.importStylesheet(dataXSL);
     }
   }

   function XSLTransform(outputElement)
   {
     if (nsbrowser) {
       var ownerDocument = createDocument();
       var newFragment = processor.transformToFragment(dataXML, ownerDocument);
       var oldLink = document.getElementById("xsllink");
       document.getElementById(outputElement).replaceChild(newFragment, oldLink);
     } else if (iebrowser) {
       //var newFragment = createDocument();
       //dataXML.transformNodeToNode(dataXSL, newFragment);
       var newFragment = dataXML.transformNode(dataXSL));
       var oldLink = document.getElementById("xsllink");
       document.getElementById(outputElement).replaceChild(newFragment, oldLink);
     }
   }

</script>

Grtz,
Geert

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.