[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: Michael <msell@xxxxxxxxxxxxxxx>
Date: Sat, 30 Oct 2004 21:26:34 +1000
activexobject java
Hey Mathew.

I've successfully done something similar to what your trying to achieve. My own attempt was in IE. I've created a function that takes the XML and XSL URL's as parameters, transforms the xml, then places the resulting xhtml into a div box that is also specified as a parameter. For the function to work, you need to have specified the div box earlier in the html... you don't need to put anything in it, just specify it. Because this was made for IE, you'll need to tweak the code for a Gecko browser and replace the 'ActiveXObject' objects.

The code is as follows:

function transformXML(xmlDocURL, xslDocURL, divID)
{
// define the local variables
var xmlDoc, xslDoc, xslTemplate, xslProcessor;
// instantiate and load the xml document
xmlDoc = new ActiveXObject("MSXML2.DomDocument");
xmlDoc.async = false;
xmlDoc.load(xmlDocURL);
// instansiate and load the passed xsl stylesheet
xslDoc = new ActiveXObject("MSXML2.FreeThreadedDomDocument");
xslDoc.async = false;
xslDoc.load(xslDocURL);
// instansiate and define an xsl template
xslTemplate = new ActiveXObject("MSXML2.XSLTemplate");
xslTemplate.stylesheet = xslDoc;
// instansiate and define an xsl processor
xslProcessor = xslTemplate.createProcessor();
xslProcessor.input = xmlDoc;
// note: if you want to pass parameters to the xsl stylesheet just prior to
// transforming the xml document, do it here (see the addParameter() function)
// for further information.
// transform the xml document into xhtml and display it
xslProcessor.transform();
divID.innerHTML = xslProcessor.output;
}


You call this function as follows:

transformXML("catalog.xml", "main.xsl", main);
transformXML("catalog.xml", "navi.xsl", navi);

I hope this helps you.

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.