using div elements(dyn) in XSLT & calling them in javasc
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 12
- Joined: Sun Oct 16, 2005 5:09 pm
using div elements(dyn) in XSLT & calling them in javasc
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>
<!-- 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>
-
- Site Admin
- Posts: 2095
- Joined: Thu Jan 09, 2003 2:58 pm
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service