First, let me say that while Phil knows more that anyone else about this area, he's helping you out of the goodness of his heart. He's not currently on contract to Saxonica though we hope to see him here from time to time.

You are supplying strings to the third and fourth arguments of ixsl:call, whereas the function expects you to supply (Javascript) functions. There's no way on the XSLT side of creating Javascript functions, other than evaluating Javascript expressions that create functions.

Having created a Javascript function, I think it should then be possible for that function to call back into XSLT using the mechanism referenced by Phil, described at

http://www.saxonica.com/ce/doc/coding/system-events.xml

However, I would need to do some experiments myself to see exactly how to make this work.

I think I would be inclined to do this differently: I would have some Javascript code on the HTML page that does the geoLocation query using the JS code you've shown us, but with the callbacks writing something to a location on the HTML page rather than calling alert(). But I guess it depends on the detail of how you want to use the geoLocation information.

Michael Kay
Saxonica

On 17/12/2012 14:56, Tom T wrote:
Hi Phil, 

I am creating a geolocation variable:

<xsl:variable name="navigator" select="ixsl:get(ixsl:window(), 'navigator')"/>
<xsl:variable name="geoLocation" select="ixsl:get($navigator, 'geolocation')"/>

I then invoke the getCurrentPosition method:

<xsl:value-of select="ixsl:call($geoLocation, 'getCurrentPosition', 'successCallback', 'errorCallback')"/>

With callback templates:

<xsl:template match="ixsl:window" mode="ixsl:successCallback">
    <xsl:value-of select="ixsl:call(ixsl:window(), 'alert', 'success')"/>
</xsl:template>

<xsl:template match="ixsl:window" mode="ixsl:errorCallback">
    <xsl:value-of select="ixsl:call(ixsl:window(), 'alert', 'failure')"/>
</xsl:template>

This causes Saxon CE to stop working.

When I implement with Javascript all is fine:

if (navigator.geolocation) {
        navigator.geolocation.getCurrentPosition(successCallback, errorCallback);    
    }

     function successCallback(position) {
      window.alert("success");
    }
    
    function errorCallback(error) {
      window.alert("Failure");
    }


Do you know why the XSLT version doesn't work?

> 'set an object variable to the position value and then make 
> another function from within this to 'trigger' the bound XSLT 
> template'. 

I haven't been able to trigger a bound XSLT template from JS, would you be able to give an example?

Thankyou


> Date: Fri, 14 Dec 2012 18:18:06 +0000
> From: pgfearo@googlemail.com
> To: saxon-help@lists.sourceforge.net
> Subject: Re: [saxon] Saxon CE and callback functions
>
> I'm not sure exactly what you mean here without a full code example,
> but the solution would doubtless require some JavaScript to facilitate
> this:
>
> It is possible to bind a template to a 0 argument JavaScript callback
> function (or event) by including an ixsl function (such as
> ixsl:window() or ixsl:get()) in the match attribute of the template.
> This ixsl function would return the object containing the function,
> the function name is then set in the mode attribute for the same
> template.
>
> The Saxon-CE documentation covers this here:
> http://www.saxonica.com/ce/doc/coding/system-events.xml
>
> for example:
>
> <xsl:template match="ixsl:window()" mode="ixsl:onhashchange">
>
> </xsl:template>
>
> Here, 'onhashchange' (though it's an event) works like a callback
> function, with window as its owner object.
>
> Note that you can't access function argument values using this
> technique so, for example, on the JavaScript side you would need to
> use the successCallBack(position) function to set an object variable
> to the position value and then make another function from within this
> to 'trigger' the bound XSLT template. XSLT instructions within the
> template could then access the 'position' object through an ixsl:get()
> call.
>
> Phil Fearon
>
> On Fri, Dec 14, 2012 at 5:26 PM, Tom T <tomxsllist@hotmail.com> wrote:
> > The html5 geolocation getCurrentPosition function utilises callback
> > functions in the form of:
> >
> > navigator.geolocation.getCurrentPosition(successCallback,
> > errorCallback,
> > {maximumAge:600000});
> >
> >
> > function successCallback(position) { }
> >
> > function errorCallback(error) { }
> >
> >
> > Is it possible to achieve the same functionality using Saxon CE and XSLT?
> >
> > ------------------------------------------------------------------------------
> > LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> > Remotely access PCs and mobile devices and provide instant support
> > Improve your efficiency, and focus on delivering more value-add services
> > Discover what IT Professionals Know. Rescue delivers
> > http://p.sf.net/sfu/logmein_12329d2d
> > _______________________________________________
> > saxon-help mailing list archived at http://saxon.markmail.org/
> > saxon-help@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/saxon-help
>
> ------------------------------------------------------------------------------
> LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
> Remotely access PCs and mobile devices and provide instant support
> Improve your efficiency, and focus on delivering more value-add services
> Discover what IT Professionals Know. Rescue delivers
> http://p.sf.net/sfu/logmein_12329d2d
> _______________________________________________
> saxon-help mailing list archived at http://saxon.markmail.org/
> saxon-help@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/saxon-help


------------------------------------------------------------------------------
LogMeIn Rescue: Anywhere, Anytime Remote support for IT. Free Trial
Remotely access PCs and mobile devices and provide instant support
Improve your efficiency, and focus on delivering more value-add services
Discover what IT Professionals Know. Rescue delivers
http://p.sf.net/sfu/logmein_12329d2d


_______________________________________________
saxon-help mailing list archived at http://saxon.markmail.org/
saxon-help@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/saxon-help