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