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 October 9th, 2007, 12:17 PM
Registered User
 
Join Date: Oct 2007
Location: Timberlea, Nova Scotia, Canada.
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSL & JavaScript

I'm a bit of an XSL Noob so bare with me here...I have a JavaScript function:

<script type="text/javascript">
        <!--

        d = new dTree('d');

        d.add(0,-1,'My example tree');
        d.add(1,0,'Node 1','example01.html');
        d.add(2,0,'Node 2','example01.html');
        d.add(3,1,'Node 1.1','example01.html');
        d.add(4,0,'Node 3','example01.html');
        d.add(5,3,'Node 1.1.1','example01.html');
        d.add(6,5,'Node 1.1.1.1','example01.html');
        d.add(7,0,'Node 4','example01.html');
        d.add(8,1,'Node 1.2','example01.html');
        d.add(9,0,'My Pictures','example01.html','Pictures I\'ve taken over the years','','','img/imgfolder.gif');
        d.add(10,9,'The trip to Iceland','example01.html','Pictures of Gullfoss and Geysir');
        d.add(11,9,'Mom\'s birthday','example01.html');
        d.add(12,0,'Recycle Bin','example01.html','','','img/trash.gif');

        document.write(d);

        //-->
    </script>

I need to be able to use the function in my XSL using the add function.

Some sample xml i am looking to transform would be similar to
<Policy>
     <id>0</id>
     <pid>5</pid>
     <name>Sample Name</name>
     <url>myurl.html</url>
</Policy>

so ideally i would write the function as:
d.add(0,5,'Sample Name','myurl.html');

which is:
d.add(id,pid,name,url);

how do i go about doing this?

Reply With Quote
  #2 (permalink)  
Old October 9th, 2007, 01:36 PM
mhkay's Avatar
Wrox Author
Points: 18,487, Level: 59
Points: 18,487, Level: 59 Points: 18,487, Level: 59 Points: 18,487, Level: 59
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

Your Javascript function looks like something that lives in an HTML page. XSLT is generally used to generate an HTML page. Clearly you can't call a function in the page that you are generating, because it's not available until you have finished. So I don't really understand what you are trying to achieve.

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference
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 & XML & NN lmod Javascript How-To 0 August 18th, 2005 03:16 PM
Javascript && keeps turnig into &amp;&amp; ayrton Pro VB.NET 2002/2003 3 June 27th, 2005 03:34 PM
MSXML4.0: 1) Getting Started & 2) First XSL & HTML BigOcean XSLT 1 February 25th, 2005 05:44 PM
Tricky Javascript/XSL '&' problem...... robster Javascript How-To 1 January 23rd, 2004 02:11 PM
How to use Javascript in XSL umeshayk XSLT 3 January 16th, 2004 11:33 AM



All times are GMT -4. The time now is 05:38 PM.


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