Elementary window operations

Added by Wendell Piez about 7 years ago


I am no Javascripter and don't know much about the windowing or event models. Happy to learn how I can exploit them in XSLT.

In SaxonJS, to scroll to the top, wouldn't I want something like

<xsl:for-each select="ixsl:page()/id('page_header')"> <xsl:sequence select="ixsl:call(.,'scrollIntoView')[current-date() lt xs:date('2000-01-01')]" /> </xsl:for-each>

This is in order to reposition the view of the page to the top (where the given element is).

But I get an error back from Javascript apparently from calling 'scrollIntoView'. So perhaps that is a dead end. Or there is something basic I am missing.

In any case ultimately I would like to be able to scroll the view to an arbitrary element, not just the top.

I am only guessing, but there must be a simple way. Any hints? Any guidance on useful functions or approaches?

Cheers, Wendell

Replies (4)

Please register to reply

RE: Elementary window operations - Added by Debbie Lockett about 7 years ago

Hi Wendell,

Possibly you just need to ensure you supply a third argument to ixsl:call(). To supply no arguments to the scrollIntoView function, use an empty array, i.e. ixsl:call(.,'scrollIntoView', [])

Does that work? (I do have some tests that use scrollIntoView, so it should be possible!)


RE: Elementary window operations - Added by Wendell Piez about 7 years ago


It does work, yes! I am reassured on several counts, including that (a) I was on the right track, while (b) the answer was by no means obvious, at least to me!

Much obliged, Wendell

RE: Elementary window operations - Added by Wendell Piez about 7 years ago

Hi again,

Also it appears the filtering predicate may not be necessary here, at any rate removing it seems to do no damage.

I now have

<xsl:template name="pageTop"> <xsl:sequence select="ixsl:call(ixsl:page()/html,'scrollIntoView',[])"/> </xsl:template>

which I simply invoke anytime I need to do this.

Is that going to work for me or am I better off keeping the filter on the result of the call?

Thanks again, Wendell

RE: Elementary window operations - Added by Michael Kay about 7 years ago

ixsl:call() declares its static result type as item()?, so the optimizer works on the assumption that there may be a result, which means that so long as the call is in a position where the result would be used if it existed, you should be OK. I don't think the filter is useful. Just avoid doing the call, for example, in the select expression of a variable that is not used.


    Please register to reply