Jump to content

loading XSL instead of XML


paetje

Recommended Posts

Normally you load an XML page and that page sends the data to the XSL file to transform it into XHTML. But can it be done an otherway like loading the XSL page witch say where to load the info from.I have a page with 4 options. Those options must show the same XML file with a different XSL file. Or is there an other better solusion?

Link to comment
Share on other sites

You could have an XML with only a reference to some XSLT. That XSLT would create create another (or better yet- the same) XML file with a reference to another XSLT. What eactly is the second XSLT going to be... hm... not entirely sure here. Perhaps a JavaScript that would detect the click and change a variable which would trigger a change in the first XSLT to switch to another XSLT in the output.

Link to comment
Share on other sites

I've done this!!The way I did it was to set up a procedure in the main page which used XMLDOM to transform a page based on 2 variables - one was the xml file name as a string, the second was the xsl file name as a string.

Sub transformfiles(xmlsource, xslsource)Dim xmldoc, xsldocSet xmldoc = CreateObject("Microsoft.XMLDOM")Set xsldoc = CreateObject("Microsoft.XMLDOM")xmldoc.load xmlsourcexsldoc.load xslsourcexmldoc.async = falsexsldoc.async = falsedocument.getelementbyid("outputsection").innerhtml = xmldoc.transformnode(xsldoc)End Sub

I then created an element which had an onclick event defined to submit 2 parameters to this procedure

<input type="button" value="view transform 1" onclick="transformfiles('xmlsource.xml','xslsource.xsl')" />

One of the key things here is that you will want to define an element like a table cell or a div element where the output is supposed to go.This will stop you from overwriting the main document with the transform and losing the buttons that work the transforms!!Enjoy - Dooberry :)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...