pulling javascript into xsl variable

48 views
Skip to first unread message

dan haig

unread,
May 7, 2013, 12:35:36 PM5/7/13
to xtf-...@googlegroups.com
Hi Everyone,

This is not exactly XTF specific, but with the advent of the bookreader in 3.1 I hoped someone here might know the answer to this.

As those who've used it know, the bookreader makes use of a url with a hash marker to manage the page number and 'mode', that is, whether it displays as a two-paged book or single page scrolling vertically. For example:



I want to create a variable using info after the hash tag, and this is proving difficult. Some simple javascript makes the info available for display on its own:

<script>document.write(window.location.hash);</script>


...but I can't find a way to pass that info into the xsl for further manipulation. YOu can't put <script.</script> inside <xsl:variable> or anything else afaics.


I looked into the user defined function shtick in msxml, but it seems that it will only work in a .net framework (shudder). 


Any suggestions appreciated, thanks!


.d

Oystein Reigem

unread,
May 12, 2013, 5:02:14 AM5/12/13
to xtf-...@googlegroups.com
Hi Dan,

You urls are like this - the value you need to access is a hash value (AKA "fragment"):

    http://....#value

Assume the value was in a query parameter instead - a query parameter of your own:

    http://....&myparameter=value

Then you could access it from the stylesheet, and your problem would be solved.

To be able to access it from the stylesheet, you *might* have to make the parameter a "pass-through tag", and declare it in some conf file(s), like crossQuery.conf or dynaXML.conf. I don't really remember. Maybe pass-through tags is for something else. But this is easy to do, at least.

I believe there is a good reason the value is a hash value. Hash values make browsers automatically scroll to anchors in the html. But assume the url had the value twice - both as a query parameter and a hash value:

    http://....&myparameter=value...#value

Then it would solve your problem without breaking anything.

(Aren't there places in XTF already where this is done? Don't links to hits in fulltext search have the hit number twice like this? Or is it something I implemented in my own application?)

Now it boils down to the following question: Are you able to change the application in all the relevant places, and add the extra query parameter to the urls?

- Øystein -


dan haig

unread,
May 15, 2013, 12:28:59 PM5/15/13
to xtf-...@googlegroups.com
Hey Øystein,

Thanks for the suggestions - sorry for the delay! I think it may be possible to get some of this info into params as you suggest, but the problem is that the user can click around inside the bookreader interface and change those post-#  values I want to read, and the server won't know what those are until after the next http request. 

I had been resigning myself to this limitation, but I should be able to at least cheat a little bit on some of this by loading up the url best I can for each page.

Cheers,
Dan



--
You received this message because you are subscribed to the Google Groups "XTF Users List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to xtf-user+u...@googlegroups.com.
To post to this group, send email to xtf-...@googlegroups.com.
Visit this group at http://groups.google.com/group/xtf-user?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

Oystein Reigem

unread,
May 15, 2013, 2:49:25 PM5/15/13
to xtf-...@googlegroups.com
Hi Dan,

I must confess I know nothing whatsoever about the bookreader.

...

After writing that I managed to find an implementation with the bookreader. I think one needs to change javascript too.  In script/bookreader/BookReader-xtf.js and perhaps more.

Cheers,

- Øystein -


dan haig

unread,
May 15, 2013, 2:59:17 PM5/15/13
to xtf-...@googlegroups.com
Hi again Øystein,

As for this:

>  I think one needs to change javascript too.  In script/bookreader/BookReader-xtf.js and perhaps more.

Having spent a little time in there, I ain't touching that madness - at least not until we get this thing launched, and maybe I'll dare to go back in there later. Would rather have a sharp poke in the eye. The guys who built that stuff (archive.org) are a pack of loons.

The bookreader is overall pretty great tho - we dug up a 'workshop' that Martin Kirk and Lisa cooked up, was a little surprised it was so buried, we never would have made it without this stuff - I believe the sample XTF with functioning bookreader is linked to in here:


We've overcome some big challenges and are pretty close to getting our pdf titles converted and getting real test tags out on our staging server.

.d


Bridger Dyson-Smith

unread,
May 15, 2013, 3:08:11 PM5/15/13
to XTF Users List
Dan, thanks for the PDF link! That will be very useful at some point.

Bridger

Reply all
Reply to author
Forward
0 new messages