RE: Calling 'transformNode' inside xsl - problems

Subject: RE: Calling 'transformNode' inside xsl - problems
From: "Chris Bayes" <Chris@xxxxxxxxxxx>
Date: Tue, 12 Sep 2000 18:33:07 +0100
Rama,
Your prob is here
document.write(xmldoc.transformNode(xsldoc));
it just writes the result to the current document
change it to
var newDoc = document.open("text/html", "replace");
newDoc.write(xmldoc.transformNode(xsldoc));

Ciao Chris

XML/XSL Portal
http://www.bayes.co.uk/xml


>-----Original Message-----
>From: owner-xsl-list@xxxxxxxxxxxxxxxx
>[mailto:owner-xsl-list@xxxxxxxxxxxxxxxx]On Behalf Of Krishnamurthy, Rama
>Sent: 12 September 2000 18:15
>To: 'xsl-list@xxxxxxxxxxxxxxxx'
>Subject: RE: Calling 'transformNode' inside xsl - problems
>
>
>
>> That doesn't give us anything to go on. Can you send your code?
>>
>	I know it is pretty confusing..but please take a look at the code
>below the form element declarations
>	where I call a for-each loop to display the pagenumbers .The 'Href'
>associated with that calls the
>	function 'displayResults(pagenumber)'. This function calls the
>'transformNode()' method which appends
>	the new page below the old page.
>
>
>	Here it is....
>
>	<?xml version="1.0"?>
>
>	<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl";>
>	<xsl:template match="/">
>
>	<SCRIPT LANGUAGE="JAVASCRIPT"><xsl:comment><![CDATA[
>	function assignCustomerValues(policynum,symbol,module,idx)
>		{
>			document.form1.policy_number.value = policynum;
>			document.form1.symbol.value = symbol;
>			document.form1.module.value = module;
>			document.form1.idx.value = idx;
>			document.form1.submit();
>	}
>	function getCookieVal (offset) {
>	        var endstr = document.cookie.indexOf (":", offset);
>	                if (endstr == -1)
>	        endstr = document.cookie.length;
>	        return unescape(document.cookie.substring(offset, endstr));
>	}
>
>		function GetCookieValue(name) {
>	        var arg = name + "=";
>	        var alen = arg.length;
>	        var clen = document.cookie.length;
>	        var i = 0;
>
>	        while (i < clen) {
>	        var j = i + alen;
>	                if (document.cookie.substring(i, j) == arg)
>
>	                return getCookieVal (j);
>	        i = document.cookie.indexOf(" ", i) + 1;
>	                if (i == 0) break;
>	        }
>
>	return null;
>	}
>
>	function SetCookie(pagenumber)
>	{
>	document.cookie = 'npages=' + escape(document.form1.npages.value)
>					+ ': ndatapage=' +
>escape(pagenumber)
>					 + ': xmlfilename='+
>escape(document.form1.xmlfilename.value)+ ':';
>
>	 }
>
>			function displayResults(pagenum)
>				{
>				var xmldoc = new
>ActiveXObject("Microsoft.XMLDOM");
>				xmldoc.async = false;
>
>xmldoc.load(location.href.substring(0,location.href.lastIndexOf("/s
>cripts"))
>+"/scripts/xmlfiles/"+ "customer"+ GetCookieValue('xmlfilename') + ".xml");
>
>				var xsldoc = new
>ActiveXObject("Microsoft.XMLDOM");
>				xsldoc.async = false;
>
>xsldoc.load(location.href.substring(0,location.href.lastIndexOf("/s
>cripts"))
>+"/scripts/xmlfiles/customer.xsl");
>
>				var node =
>xsldoc.selectSingleNode("//xsl:for-each[@select='Customers/p1/Customer']");
>				node.setAttribute("select",
>'Customers/p'+String(pagenum)+'/Customer');
>
>
>document.write(xmldoc.transformNode(xsldoc));
>
>				}
>
>
>	    ]]></xsl:comment></script>
>	<html>
>		<head>
>			<title>Agent Web - Search Results
>(Customers)</title>
>		</head>
>		<body bgcolor="#FFFFFF">
>
>				<form id="form1" name="form1" method="post"
>action="closebook_frameset.asp" >
>				<input type="hidden" id="policy_number"
>name="policy_number"/>
>				<input type="hidden" id="symbol"
>name="symbol"/>
>				<input type="hidden" id="module"
>name="module"/>
>				<input type="hidden" id="idx" name="idx"/>
>				<input type="hidden" id="flag" name="flag"/>
>				<input type="hidden" id="nlncount"
>name="nlncount"/>
>				<input type="hidden" id="ndatapage"
>name="ndatapage"/>
>				<input type="hidden" id="npages"
>name="npages"/>
>				<input type="hidden" id="xmlfilename"
>name="xmlfilename"/>
>
>				<font face="arial" size="2"
>style="color:black"><strong>Page:</strong></font>
>					<xsl:for-each
>select="Customers/PageNumber">
>					<xsl:element name="a">
>						<xsl:attribute name="HREF">
>
>javascript:displayResults('<xsl:value-of select = "."/>')
>						</xsl:attribute>
>						<xsl:attribute name="STYLE">
>							color:#a52a2a;
>							white-space:nowrap;
>
>text-decoration:none;
>						</xsl:attribute>
>						<xsl:value-of select = "."/>
>						</xsl:element>
>					</xsl:for-each>
>
>				<TABLE width="400" border="0"
>cellspacing="0" cellpadding="0" whitespace="nowrap">
>					<tr bgcolor="#a52a2a">
>						<td whitespace="nowrap"
>valign="bottom" align="left" width="130">
>							<u><strong><font
>face="arial" size="2" color="#FFFFFF">Name</font></strong></u>
>						</td>
>						<td whitespace="nowrap"
>valign="bottom" align="left" width="160">
>							<u><strong><font
>face="arial" size="2" color="#FFFFFF">Address </font></strong></u>
>						</td>
>						<td whitespace="nowrap"
>valign="bottom" align="left" width="120">
>							<u><strong><font
>face="arial" size="2" color="#FFFFFF">City/State </font></strong></u>
>						</td>
>						<td whitespace="nowrap"
>valign="bottom" align="left" width="60">
>							<u><strong><font
>face="arial" size="2" color="#FFFFFF">Zip </font></strong></u>
>						</td>
>						<td whitespace="nowrap"
>valign="bottom" align="left" width="60">
>							<u><strong><font
>face="arial" size="2" color="#FFFFFF">Status </font></strong></u>
>						</td>
>					</tr>
>
>		 		<xsl:for-each
>select="Customers/p1/Customer">
>
>			<TR>
>
>		        <TD>
>					 <xsl:element name="a">
>		    			<xsl:attribute name="HREF">
>
>javascript:assignCustomerValues('<xsl:value-of select =
>"policy_number"/>','<xsl:value-of select =
>"symbol"/>','<xsl:value-of select
>= "module"/>','<xsl:value-of select = "idx"/>')
>						</xsl:attribute>
>						<xsl:attribute name="STYLE">
>							color:#a52a2a;
>							white-space:nowrap;
>						</xsl:attribute>
>						 <xsl:value-of
>select="insured_first_name_1"/>
>						 <xsl:value-of
>select="insured_last_name_1"/>
>					 </xsl:element>
>
>				</TD>
>
>				<TD>
>					<xsl:attribute name="STYLE">
>						white-space:nowrap;
>					  </xsl:attribute>
>					<xsl:value-of
>select="street_number"/>
>					<xsl:value-of select="street_name"/>
>					<xsl:value-of
>select="second_street_name"/>
>				</TD>
>
>				<TD>
>					<xsl:attribute name="STYLE">
>						white-space:nowrap;
>					</xsl:attribute>
>					 <xsl:value-of select="city"/>
>					 <xsl:value-of select="state_code"/>
>				</TD>
>
>				<TD>
>					<xsl:value-of select="zip"/>
>				</TD>
>
>			</TR>
>
>		    </xsl:for-each>
>		</TABLE>
>	 </form>
>	 </DIV>
>
>	</body>
>	</html>
>	</xsl:template>
>	</xsl:stylesheet>
>
>
> XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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


Current Thread