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 October 9th, 2007, 12:17 PM
Registered User
 
Join Date: Oct 2007
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?

 
Old October 9th, 2007, 01:36 PM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
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





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





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