Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 27th, 2004, 09:41 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Problem with JavaScript in XSL

Hi,need some help here... :|

i am working with XML and XSL with little JavaScript inside.In XSL i put some of the XML nodes in <div> tags. There is a simple function as well:

<script language="JavaScript">
function showhide(divID, imgName) {
    if (document.all(divID).style.display == "none") {
        document.all(divID).style.display = "block";
        document.all(imgName).src = "minus.gif";
    } else {
        document.all(divID).style.display = "none";
        document.all(imgName).src = "plus.gif";
    }
}
</script>

So, the problem is there: when i get to <subnode> an error occurs: 'document.all(...).style.display' is null or not an object.

this is the XML:

<main>
   <node>
      <subnode>
      </subnode>
   </node>
</main>

All three are put in <div> so i can hide or show them and its ok with first and second level - <country> and <rule>.

any ideas???
thanks in advance :)

 
Old August 27th, 2004, 09:49 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

I don't understand, is this a javascript problem or an xml one? Xml has no concept of a dom document, where is this code running?

--

Joe (Co-author Beginning XML, 3rd edition)
 
Old August 27th, 2004, 10:22 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I dont know where is the problem too - i suppose it is in JavaScript, but it may be in XSL code.

Here is the XSL problem part:

<img id="imgName" src="plus.gif" OnClick="showhide('divID','imgName')"/>#160;
NodeName
<div id="divID" style="display:none">
  <TABLE border="1" width="70%">
   <TR>
   <TD align="center"><B>From</B></TD>
   <TD align="center"><B>To</B></TD>
   <TD align="center"><B>Value</B></TD>
   <TD align="center"><B>Percent</B></TD>
   <TD align="center"><B>Base</B></TD> </TR>
   <xsl:apply-templates/>
  </TABLE>
</div>

But the same code is working fine with parent nodes.
It is on my computer still.

 
Old August 30th, 2004, 09:12 AM
Registered User
 
Join Date: Aug 2004
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

well i fixed it by changing 'document.all' with 'documnet.getElementById' and adding 'generate-id(.)' to the <div> ID,so every node should has unique id. But now there is another problem:
This code is working fine in IE6 but not in Mozilla 1.8a2.

<xsl:for-each select="following-sibling::node()[$count]">
    <xsl:value-of select="@attribute"/>
</xsl:for-each>

In Mozilla it is working only like this:
<xsl:for-each select="following-sibling::*">
but i don't need all nodes at once.

So it seems i have to change 'node()[$count]' with something, but what??????






Similar Threads
Thread Thread Starter Forum Replies Last Post
Javascript in Xsl using-Xalan-Problem angeshwar XSLT 1 May 7th, 2008 12:36 AM
xsl javascript problem smi13y XSLT 1 December 26th, 2006 07:27 PM
XSL maybe javascript. suri_1811 XSLT 1 November 3rd, 2006 12:20 PM
Javascript with XSL drdexter33 XSLT 2 January 19th, 2006 01:36 PM
Tricky Javascript/XSL '&' problem...... robster Javascript How-To 1 January 23rd, 2004 02:11 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.