Re: [xsl] setting and returning variable values from the source file using javascript

Subject: Re: [xsl] setting and returning variable values from the source file using javascript
From: "M. David Peterson" <conners_dad@xxxxxxx>
Date: Thu, 4 Sep 2003 04:32:03 -0600
Thanks for the reply David!  Below is the entire javascript code block... 
posCount is simply a function that returns the position count.. I set this 
up because I needed to pull the current position within the 
$historySrc//history/visit loop while I was in the context of the $FTR_Links 
loop.  It shouldn't have any effect on anything else as far as I can tell 
but at this point I am ruling NOTHING out ;)

If I understand what your saying is that there is the potential that the XSL 
transform could potentially outpace the javascript process given that they 
are performed by two separate processes... totally makes sense!  I do 
realize I am taking risks with this particular approach and its becoming 
more and more obvious that these risks are probably not worth it.

However, if this is the case I'm still puzzled as to why the NaN.  NaN is a 
typical return for XSLT and as such I guess I can understand the notion that 
.NET XslTransform() is just placing NaN in place of the values it is unable 
to retrieve from the javascript process...  I have attempted to begin the 
javascript process outside of this specific for-each loop, but as you said 
there is no guarentee as to the order of the processing so this is really 
just a hack on top of a prayer.  My attempt returned the same result.

Of course the proper solution would be to ensure that the loc, subloc, and 
id are indexed against the master link list before its written to the 
history file elimanating the need to build this catch-all.  None-the-less it 
is something I would like to get to the bottom of if for no other reason 
than my own sanity and satisfaction. Would make a good case study proving 
the inneffectiveness of such a solution as well.  :) ;)

Your current and future insight is much appreciated!

The complete javascript block...

<msxsl:script language="jscript" implements-prefix="my"><![CDATA[

        var pos = 0;
        var lid;
        var loc = "home";
        var subloc = "main";

        function setLid(value){

            lid = value;
            return 0;

        function setPath(n_loc, n_subloc){

            loc = n_loc;
            subloc = n_subloc;

            return 0;


        function returnLoc(){

            return loc;

        function returnSubloc(){

            return subloc;

        function returnPath(){

            var s = loc.concat(subloc);

        function returnLid(){

            return lid;

        function posCount(inc){

            if (inc == 'true'){
                pos = pos + 1;
                return pos;

                return pos;



Best Regards,


----- Original Message ----- 
From: "David Carlisle" <davidc@xxxxxxxxx>
To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
Sent: Thursday, September 04, 2003 4:00 AM
Subject: Re: [xsl] setting and returning variable values from the source 
file using javascript

> I can't see any numeric operations in your posted code that could lead
> to NaN (but there must be other code around that you havent shown, eg
> the defn of posCount)
> However do you _really_ need to use javascript here?
> Given that XSL gives no assurances as to the evaluation order that is
> used when evaluating a for-each loop, embedding constructs from an 
> imperative
> language inside the loop is always going to be risky. As the interface
> to javscript is processor specific you only have one processor to worry
> about and it may hapen to work there, but it its always going to be by
> luck rather than specification.
> David
> ________________________________________________________________________
> This e-mail has been scanned for all viruses by Star Internet. The
> service is powered by MessageLabs. For more information on a proactive
> anti-virus service working around the clock, around the globe, visit:
> ________________________________________________________________________
>  XSL-List info and archive:

 XSL-List info and archive:

Current Thread