Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XSLT
Password Reminder
Register
| FAQ | Members List | Search | Today's Posts | Mark Forums Read
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 tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old August 27th, 2004, 09:41 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
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 :)

Reply With Quote
  #2 (permalink)  
Old August 27th, 2004, 09:49 AM
joefawcett's Avatar
Wrox Author
Points: 9,763, Level: 42
Points: 9,763, Level: 42 Points: 9,763, Level: 42 Points: 9,763, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Exeter, , United Kingdom.
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)
Reply With Quote
  #3 (permalink)  
Old August 27th, 2004, 10:22 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
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.

Reply With Quote
  #4 (permalink)  
Old August 30th, 2004, 09:12 AM
Registered User
 
Join Date: Aug 2004
Location: , , .
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??????

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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



All times are GMT -4. The time now is 02:45 AM.


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