Re: [xsl] getting javascript into an xsl variable

Subject: Re: [xsl] getting javascript into an xsl variable
From: Michael Dykman <mdykman@xxxxxxxxx>
Date: Tue, 28 May 2013 16:32:50 -0400
The most you can hope to do is to put a string-encoding of JavaScript
into an XSL variable.  JavaScript can not run until after the
transformation has taken place and rendered (typically as HTML) into a
JavaScript environment (ie. a browser).  By the time it has become
executable as a script node in an HTML document, all memory of XSL
origins are gone.


On Tue, May 28, 2013 at 4:14 PM, dan haig <haig@xxxxxxx> wrote:
>
> G'day,
>
> I am trying to get my XTF to read a bit of javascript into an XSL
> variable. I know the drill about msxml and all that, not going there
> obviously, but I wonder why this seemingly is impossible.
>
> So, given a url:
>
> http://127.0.0.1:8090/xtf/view?docId=eliot_p/eliot_p.01.xml;chunk.id=eliot_p.volume01.chapter10.pdf;toc.depth=1;toc.id=;page=69;brand=default#page/68/mode/2up
>
> ...I want to be able to work with the post-hash stuff,
> page/68/mode/2up in this case. I can get it to display inline with the
> text via this:
>
> <script type="text/javascript">document.write(window.location.hash);</script>
>
>
> ...and, failing elsewhere and grasping at straws, have at least
> managed to make this also work to display inline and was hoping I
> could then get at the element thru some bizarre circuitous route, as
> one often must do with xslt:
>
>
>  <xsl:element name="posthash"><script
> type="text/javascript">document.write(window.location.hash);</script></xsl:element>
>
>
> ...but I can't do anything with the string, can't get it into a
> variable, can't manipulate it to construct a new URL (the bookreader
> viewer depends on the posthash page and mode values which change as
> the user reads, and I don't want them to lose state if they, for
> instance, click a 'clear search hits' link). copy-of also worked to
> render the string inline, but you can't make a variable out of that or
> put it thru functions either it seems.
>
> All the ink I've seen spilled out there declares it impossible to pull
> javascript into an XSL variable save thru msxml. Is this still true?
>
> Thanks,
> Dan
>



--
 - michael dykman
 - mdykman@xxxxxxxxx

 May the Source be with you.

Current Thread