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

Go Back Function When Using MSXML Transforms

Subject: Go Back Function When Using MSXML Transforms
From: "Beverly L. Parmelee" <parmelee@xxxxxxxxxxxxx>
Date: Fri, 21 Nov 2003 22:15:31 -0500
html back function
Is there a way to get the browser's go back function to work when using MSXML transforms? The example code below (4 files) works fine for moving forward through the transformations, so I'm looking for how to modify it for going back. Thanks!

index.xsd..................
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified">
<xsd:element name="INVENTORY">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ITEM" maxOccurs="unbounded">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="ITEM_NO" type="xsd:positiveInteger"/>
<xsd:element name="SUMMARY_INFO" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>


index.xml...............................
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<?xml:stylesheet type="text/xsl" href="index.xsl"?>
<INVENTORY xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="index.xsd">
<ITEM>
<ITEM_NO>1</ITEM_NO>
<SUMMARY_INFO>Summary Info</SUMMARY_INFO>
</ITEM>
<ITEM>
<ITEM_NO>2</ITEM_NO>
<SUMMARY_INFO>Summary Info</SUMMARY_INFO>
</ITEM>
<ITEM>
<ITEM_NO>3</ITEM_NO>
<SUMMARY_INFO>Summary Info</SUMMARY_INFO>
</ITEM>
</INVENTORY>


index.xsl.....................................
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<head>
<script language="javascript" type="text/javascript">
<xsl:comment> //
function transform(xsl_page,user_choice)
{
var IE4, NS4, W3C;
IE4 = (document.all) ? true : false;
NS4 = (document.layers) ? true : false;
// else document.getElementById and !document.all
W3C = (document.getElementById) ? true : false;


// load the called stylesheet
if (IE4)
{
var xsltOldProcessor = new ActiveXObject("Msxml2.XSLTemplate.4.0");
var xslNewDoc = new ActiveXObject("Msxml2.FreeThreadedDOMDocument.4.0");
}
else
{
var xsltOldProcessor = new xsltProcessor();
var xslNewDoc = document.implementation.createDocument("", "", null);
xslNewDoc.addEventListener("load", onload, false);
}
var xslNewProcessor;


                        xslNewDoc.async = false;
                        xslNewDoc.resolveExternals = false;
                        xslNewDoc.load(xsl_page);

if ( xslNewDoc.parseError.errorCode != 0 )
{
alert("You have error " + xslNewDoc.parseError.reason);
}
else
{
if (IE4)
{
var xmlOldDoc = new ActiveXObject("Msxml2.DOMDocument.4.0");
}
else
{
var xmlOldDoc = document.implementation.createDocument("", "", null);
xmlOldDoc.addEventListener("load", onload, false);
}


                             // load the calling stylesheet
                             xsltOldProcessor.stylesheet = xslNewDoc;
                             xmlOldDoc.async = false;
                             xmlOldDoc.resolveExternals = false;
                             xmlOldDoc.load("index.xml");

if (xmlOldDoc.parseError.errorCode != 0)
{
alert("You have error " + xmlOldDoc.parseError.reason);
}
else
{
xslNewProcessor = xsltOldProcessor.createProcessor();
xslNewProcessor.input = xmlOldDoc;
// pass the function parameter to the stylesheet and transform
xslNewProcessor.addParameter("user_input", user_choice);
xslNewProcessor.transform();


if (IE4)
{
if (document.all)
{ document.body.innerHTML = xslNewProcessor.output;
}
}
else if (NS4)
{
if (document.lyrBackground.document)
{ document.body.innerHTML = xslNewProcessor.output;
}
}
else
{
if (document.getElementById)
{ document.body.innerHTML = xslNewProcessor.output;
}
}
}
}
}
// End</xsl:comment>
</script>
</head>
<body leftmargin="0" marginwidth="0" topmargin="0">
<xsl:variable name="item" select="1"/>
<xsl:copy-of select="INVENTORY/ITEM[ITEM_NO=$item]/SUMMARY_INFO"/>
<xsl:copy-of select="$item"/>
<br/>
<a>
<xsl:attribute name="href">#</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:text>transform('detail.xsl',</xsl:text>
<xsl:value-of select="$item"/>
<xsl:text>)</xsl:text>
</xsl:attribute>
Go To Item #<xsl:value-of select="INVENTORY/ITEM[ITEM_NO=$item]/ITEM_NO"/> Detail
</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>


detail.xsl...............................................
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="user_input"/>
<xsl:output method="html" indent="yes"/>
<xsl:template match="/">
<html>
<body leftmargin="0" marginwidth="0" topmargin="0">
<a>
<xsl:attribute name="href">#</xsl:attribute>
<xsl:attribute name="onclick">
<xsl:text>transform('detail.xsl',</xsl:text>
<xsl:value-of select="$user_input+1"/>
<xsl:text>)</xsl:text>
</xsl:attribute>
Go To Item #<xsl:value-of select="INVENTORY/ITEM[ITEM_NO=$user_input+1]/ITEM_NO"/> Detail
</a>
</body>
</html>
</xsl:template>
</xsl:stylesheet>




XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list


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.