Re: [xsl] extending xsl with javascript

Subject: Re: [xsl] extending xsl with javascript
From: april@xxxxxxxxxxx
Date: Thu, 8 Nov 2007 13:53:06 -0500 (EST)
Hi,

In this example the $pageMode would come from the url, e.g.:

myXML2HTMLpage.xml?mode=List


I don't know of any way to get at command line parameters from xsl. If I could access them directly then that is the preferred pathway. 

Please note, although maybe I didn't state my original question clearly, this is a specific example of a general problem of using JavaScript to populate a XSL variable or parameter. {Or creating XSL functions as wrappers to javascript functions). I have seen the web site: http://www.exslt.org/, but unfortunately I am having difficulty understanding the information on this site and am concerned that I may spend hours/days digesting this information and find out that it won't work so some reason. It was my hope that maybe this forum could point me in the right direction.

I think maybe I have found what I'm looking for on cafeconleche.org:

http://www.cafeconleche.org/slides/xmloneaustin2001/cuttingedge/116.html

I havn't tried it yet, but hopefully this will open the door to using JavaScript to return data to the XSL stylesheet for use while processing the XML

Thanks for your help.

Kind Regards,
April




----- Original Message -----
From: cknell@xxxxxxxxxx
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Thursday, November 8, 2007 1:15:25 PM (GMT-0500) America/New_York
Subject: RE: Re: [xsl] extending xsl with javascript

How is it that you are accomplishing the transformation that leads you to believe that Javascript is the way to set the value of a parameter that you are passing to the XSLT?
-- 
Charles Knell
cknell@xxxxxxxxxx - email



-----Original Message-----
From:     april@xxxxxxxxxxx
Sent:     Thu, 8 Nov 2007 13:03:06 -0500 (EST)
To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject:  Re: [xsl] extending xsl with javascript

Hi,

The branching logic refers to accessing different templates within a stylesheet depending on the usage scenario. For example:

<xsl:choose>
    <xsl:when test=[$pageMode='List']>
      <xsl:call-template name='ListPage'/>
    </xsl:when>
    <xsl:when test=[$pageMode='Edit']>
      <xsl:call-template name='EditPage'/>
    </xsl:when>
    <xsl:otherwise>
      <xsl:call-template name='ErrorPage'/>
    </xsl:otherwise>
</xsl:choose>


I'm sorry if I didn't give a good example of why I want to use JavaScript within XSL, but it was the best example I could think of at the moment.

For the example above, how would you populate the pageMode variable ($pageMode) via JavaScript?

Thanks in advance for your help and sorry for the confusion.

Regards,
April





----- Original Message -----
From: "Steve" <subsume@xxxxxxxxx>
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Sent: Thursday, November 8, 2007 12:46:44 PM (GMT-0500) America/New_York
Subject: Re: [xsl] extending xsl with javascript

Could someone explain 'branching logic'?

-Steve

On Nov 8, 2007 12:45 PM, Colin Adams <colinpauladams@xxxxxxxxxxxxxx> wrote:
> That would be sensible if the OP's question were actually about XSLT,
> but it looks to me like it is actually a dynamic HTML question (and
> therefore off-topic here).
>
>
> On 08/11/2007, cknell@xxxxxxxxxx <cknell@xxxxxxxxxx> wrote:
> > Why not keep things simple and let XSLT do the branching?
> > --
> > Charles Knell
> > cknell@xxxxxxxxxx - email
> >
> >
> >
> > -----Original Message-----
> > From:     april@xxxxxxxxxxx
> > Sent:     Thu, 8 Nov 2007 12:11:14 -0500 (EST)
> > To:       xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Subject:  [xsl] extending xsl with javascript
> >
> > Hi,
> >
> > I am interested using JavaScript with my xsl templates to control branching logic but do not have a clue where to start. For example one ability I'd like to create is to be able to access command line parameters to a page:
> >
> > myXML2HTMLpage.xml?mode=List
> >
> >
> > I have come across a couple of web sites but they all make my head spin (it is not pretty!) and I'm not sure if I'm ready to embrace a third party library (especially since hugs are no longer allowed in US schools...?)
> >
> > Can anyone suggest a good, introductory, place to start? hopefully with examples...
> >
> >
> > Thanks in advance for your help!
> >
> > Kind Regards,
> > April

Current Thread