Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you use more than 1 stylesheet for one XML?

Status
Not open for further replies.

Endbringer

Technical User
Jan 18, 2002
28
0
0
US
Is it possible to have more than one stylesheet used against one XML? Let's say I have a default view for a XML file. Depending on what a user does, is it possible to redisplay that using a different stylesheet?

Robert
 
Yes it is possible to have multiple sytlesheets that can be applied to an XML document in different instances. You can probably do this using JavaScript. I personally do this using ASP and use the transformNode command which is similarly available in JavaScript using the MSXMLDOM I beleive.
 
Here is one way it can be done using javascript:

Code:
function openNewXSL(blah)
{
	var newWindow=window.open('','','toolbars=no, height=175, width=550')

	var objXml = new ActiveXObject("Microsoft.XMLDOM")
	objXml.async = false
	objXml.load("XMLoutput.xml")

	var theNode= "Server/Database[DatabaseName='"+blah+"']";

	var objNode = objXml.selectSingleNode(theNode);

	var objXsl = new ActiveXObject("Microsoft.XMLDOM")
	objXsl.async = false
	objXsl.load("DifferentXSL.xsl")	

	newWindow.document.open()
	newWindow.document.write(objNode.transformNode(objXsl))
	newWindow.document.close()
}
This brings up the new styling of the xml document into a popup window, but can be easily modified to overwrite the page if desired.

Hope this helps
~Deeba~
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top