Page 1 of 1

using div elements(dyn) in XSLT & calling them in javasc

Posted: Sun Oct 16, 2005 5:20 pm
by sujatha
I have a dvds.xml files and dvds.xsl file. I use div element in XSLT (for showing one set of child elements at a time) and trying to retrieve that in javascript to show the rest of the child element when a next button is clicked. But I am getting an runtime error (object required when using "document.getElementById(div)" ) whenever trying to retrieve the div id from XSLT in javascript. If anybody know any possible solution for this please le me know.

<!-- this is dvds.xsl file which uses dvds.xml file -->
<?xml version="1.0" encoding="ISO-8859-1" ?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" version="1.0" encoding="iso-8859-1" indent="yes"/>
<xsl:param name="owner" select="'2.'"/>
<xsl:template match="/">
<html>
<script language="javascript" >

function switchdiv() {
showHide("disp");
}

function hide()
{
var counter=1;

var i=1;
document.getElementById(divshow).style.display= 'show';
i=i+1;
counter = counter + 1;
}

function showHide(ids)
{
var elem = document.getElementById(disp);

document.getElementById(elem).style.display = 'show';
}

</script>

<body> Number of Multivalues in the Record:= <xsl:text/>
<td>
<xsl:value-of select="count(/ELG-MONITOR_record/ASSOC_3-MV)"/>
</td>
<br/>
<xsl:for-each select="//ASSOC_3-MV">
<xsl:variable name="i" select="position()"/>
<xsl:element name="div" namespace="http://www.w3.org/1999/xhtml;">
<xsl:attribute name="id">divshow<xsl:value-of select="position()"/></xsl:attribute>
<xsl:attribute name="style">
<xsl:if test="position() != 2"> display: none </xsl:if>
</xsl:attribute>
<table border="1" bgcolor="lightblue">
<TR>
<th align="left">RULE_NO</th>
<th align="left">RULE_QUANTITY</th>
<th align="left">RULE_VALUE</th>
<input type="button" id="click" name="click" value="NextRule" onclick="hide();"/>
</TR>
<tr>
<td>
<xsl:value-of select="RULE_NO"/>
</td>
<td>
<xsl:value-of select="ASSOC_3-MS/RULE_QUANTITY"/>
</td>
<td>
<xsl:value-of select="ASSOC_3-MS/RULE_VALUE"/>
</td>
</tr>
</table>
</xsl:element>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>

Following is the sample dvds.xml file

<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="dvds.xsl"?>
<ELG-MONITOR_record>
<_ID>DW*286112233</_ID>
<PREP_DATE>08 Jun 2194</PREP_DATE>
<PREP_TIME>12:56:44</PREP_TIME>
<ASSOC_3-MV>
<RULE_NO>1</RULE_NO>
<LOOKBACK_MONTHS>3</LOOKBACK_MONTHS>
<ASSOC_3-MS>
<RULE_QUANTITY>20000</RULE_QUANTITY>
<RULE_VALUE>1500</RULE_VALUE>
</ASSOC_3-MS>
</ASSOC_3-MV>

<ASSOC_3-MV>
<RULE_NO>2</RULE_NO>
<ASSOC_3-MS>
<RULE_QUANTITY>19000</RULE_QUANTITY>
<RULE_VALUE> 2500</RULE_VALUE>
</ASSOC_3-MS>
<ASSOC_3-MS>
<RULE_QUANTITY>18000</RULE_QUANTITY>
<RULE_VALUE> 3500</RULE_VALUE>
</ASSOC_3-MS>
</ASSOC_3-MV>

<ASSOC_3-MV>
<RULE_NO>3</RULE_NO>
<ASSOC_3-MS>
<RULE_QUANTITY>16000</RULE_QUANTITY>
<RULE_VALUE> 500</RULE_VALUE>
</ASSOC_3-MS>
<ASSOC_3-MS>
<RULE_QUANTITY>15000</RULE_QUANTITY>
<RULE_VALUE> 400</RULE_VALUE>
</ASSOC_3-MS>
</ASSOC_3-MV>
</ELG-MONITOR_record>

Posted: Mon Oct 17, 2005 9:52 am
by george
Hi,

This looks like a Java Script problem. I suggest you debug first the Java Script you obtain and when that works ok then we can help you if you are not able to get the desired JavaScript as the result of your XSLT transformation.

Best Regards,
George

Re:XSLT

Posted: Tue Oct 18, 2005 7:33 pm
by sujatha
Thanks for your reply, I got the soulution and, yes the problem is with the code in the javascript.

Posted: Sun Feb 05, 2006 3:02 pm
by msudalai
How can I debug a java script on oxygen editor?
I know that oxygen is for XML / XSL / XSLT.

Posted: Sun Feb 05, 2006 3:02 pm
by msudalai
msudalai wrote:How can I debug a java script on oxygen editor?
I know that oxygen is for XML / XSL / XSLT.

Posted: Mon Feb 06, 2006 12:41 am
by sujatha
You need to download microsoft debugger to debug the javascript.