Brett's Blog
Edit     New

Sunday, August 12, 2007

XqUSEme

Feel free to leave comments here pertaining to my XqUSEme extension for Firefox.

19 Comments:

  • No matter what I try, I just get a pop up error: "Finding root of tree: the context item is undefined".

    I just tried a trivial XPath (which is valid XQuery): //a

    I also tried the more verbose

    for $a in //a
    return $a

    And received the same thing.

    By Blogger Kevin, at Sunday, 13 April, 2008  

  • Hi Kevin,

    If you are using the default Saxon-B, the context node can be gotten by "doc()":

    doc()//a

    or

    for $a in doc()//a
    return $a

    If you have installed BDBXML, "collection()" can be used.

    Beyond this, remember that if you are browsing an HTML document with the XHTML namespace, (i.e., with <html xmns="http://www.w3.org/1999/xhtml"> as the root), you have to put an XQuery namespace declaration or default namespace declaration in the head:

    declare default element namespace "http://www.w3.org/1999/xhtml";

    or

    declare namespace html = 'http://www.w3.org/1999/xhtml';

    (in the latter case, you have to prefix all HTML element references (like 'a' in your case) with 'html')

    By Blogger Brett, at Sunday, 13 April, 2008  

  • No joy.

    I tried

    declare default element namespace "http://www.w3.org/1999/xhtml";

    doc()//tr

    and got a pop up with an ad from eBay and nothing else (there was no ad from eBay in the source document I queried).

    I also tried 'doc//a' and got a pop-up with a bunch of what looked like img links that did not really point to any images. However, when I tried to look at the source, the browser crashed.

    By Blogger Kevin, at Tuesday, 29 April, 2008  

  • Can you give me a sample page? It's working for me when I try it on other pages. However, I do need to do a better job of creating a document with a particular type (right now, it uses document.write I believe). Sometimes, for example, while the code says it has made a link, it doesn't look that way in the output. I wanted to make an upgrade that fixed this, but I've been slow on this, partly because I'd like to make it work with FF3 but the betas have some big bugs with the technology I need (LiveConnect). However, the XQuery does work to produce the right code if you can grab the source.

    For now, I'd just suggest trying again and looking at the source code which was created, and pasting it in a new document so you can move it into a new HTML file and then view the results that way.

    As far as the eBay ad, if that was not from your service provider, perhaps you had opened the XQuery dialog earlier when you WERE on a document which had such an ad? (or maybe it was an adserver that changed the type of ads)? When you grab the whole "a", you'd be getting images within the element too.

    Sorry for the trouble and hope you can get it to work this time around.

    By Blogger Brett, at Wednesday, 30 April, 2008  

  • I was using it to look at pages from titantv.com (you must log in to actually see the TV guide pages).

    Originally, I wanted to see if I could select the advertisement rows using this XPath:

    //tr[td/@class='gridBannerRowHeader' or td/@class='gridBannerRowCell']

    I was using the simplier XPaths to try to figure out the XqUSEme extension.

    Like I mentioned, I _tried_ to look at the resulting source: Firefox crashed.

    What sort of output should I expect?

    By Blogger Kevin, at Wednesday, 30 April, 2008  

  • Sorry, still no access to non-Mac machine to check out an XQuery on the specific page yet (though I do see from the site you refer to that the page does generate ads so it could have pulled an eBay ad at that time it reloaded for the results). However, when you say it crashed, do you mean it crashes every time? I can't be held responsible, but I really don't think there is anything at all to worry about with crashes; that happens to me, and trying things again doesn't cause the same result.

    The output may or may not appear like regular HTML. If if doesn't appear like HTML, it might just appear like text or whatever. But the important thing is that you'll need to view the source to grab the source anyways, and it might look different after you paste the source elsewhere.

    And don't forget the doc() in the beginning of the path, as well as the namespace declaration if you do try it again.

    By Blogger Brett, at Wednesday, 30 April, 2008  

  • Hi Brett. Nice work! But, I'm getting an error on Firefox 3.0.3 on OS X 10.5 (Leopard). The error is this:

    InternalError: Java class net.sf.saxon.xqj.SaxonXQConnection has no public field or method named "getStaticContext"

    ...which might have something to do with the binding between javascript and java?

    By Blogger Chris, at Wednesday, 22 October, 2008  

  • Hi Chris,

    First, please be aware that you should get the version in the sandbox. I made the big mistake in the currently approved version, of saving the user data in the extension's folder, which means that for the next time it gets updated (though only this time since I've since fixed it), it will overwrite your old user data (user data being the site-specific XQueries you can save). In the change log, I've made notes on how those upgrading can preserve their old data, but it should be much safer to actually use the Sandbox version in this case.

    Unfortunately, XqUSEme (and my XSL Results extension) do not work on the Mac. I'm not fully clear on the extent this is due to lagging Java support on the Mac, to any platform-specific code in Firefox relating to LiveConnect, or to the way I've compiled Saxon and my own wrapper (though I did try compiling once under 1.5 and though I thought I got it working, I could not replicate); however, I do know that it is not strictly a LiveConnect issue (binding of Java/JavaScript) since it does work fine on Windows (and Linux from what I'm told, if Java is installed/enabled).

    The source code is provided, so you are welcome to try compiling it yourself if you like (I use a wrapper class of my own as well as a loader provided in the Java Firefox Extension project). Be aware that I believe there were some changes to Saxon that would break the current implementation if applied, so you should probably compile an earlier Saxon implementation (9.0.0.6 was the latest one I can confirm works) if you did want to try this yourself. Java 1.6 is not supported on the Mac, but all of the code should compile (as I believe I've already done) under Java 1.5.

    There is to be a complete revamping of LiveConnect around the corner, but documentation is lacking (and the Mac would still need to update its Java support to 1.6 to take advantage of it anyways). But this might solve the problem down the road if the problem was with LiveConnect code in Firefox that was platform-specific.

    So, all I can suggest is that if you have the dual-boot system, using it on the Windows side. Wish I could be of more help!

    Brett

    By Blogger Brett, at Wednesday, 22 October, 2008  

  • Hi Brett,

    The Mac did finally get Java 6, although only on 64-bit Intel machines. Anyway...
    Part of my interest in XQUSEME comes from the fact that I've used the same technique (from Simile's Piggy Bank) in my own extension (Firegoose, a data-sharing extension for bioinformatics websites). I've been trying to advocate, both in the Firefox and Java forums for this technique to become more officially supported. It seems to break in some subtle way with every new release.
    Have you seen problems with the latest release 10 of Java 6?

    By Blogger Chris, at Tuesday, 18 November, 2008  

  • Hi Chris,

    Although I haven't looked into it, I think it's really great to hear about progress in IT facilitating medical-related fields like bioinformatics.

    As far as Java 6 release 10, I haven't tried it. However, what I think should be good news is that that is the release which has apparently revamped LiveConnect, so rather than furthering our hackish techniques to make things work, I think we may all be able to start fresh (assuming our audiences can upgrade to this version), using a technique which should also help familiarize us with a syntax used in other plugins besides Java as well.

    See:
    this ...and probably more importantly, the new documentation for it

    Before I knew about the above, I wrote this post which might have some links that are still useful.

    If you do have success with it, it'd be great to hear about it on your blog (Digithead's Lab, right?).

    Hope all goes well.

    thanks and take care,
    Brett

    By Blogger Brett, at Wednesday, 19 November, 2008  

  • I am fairly new to Xquery, but I created a query using Stylus Studio. When I use their program it reads two xml files and returns a html report. When I enter the xquery into XqUSEme and click "perform xquery" nothing happens. No error, not even a pause for computing. Just nothing.

    I must be missing some fundamental operation. I suspect it may have to do with the "meta information" that appears at the end of the xquery. I think this because I did not write this part of the code and cannot find out what it does.

    any ideas??

    By Blogger JD, at Wednesday, 01 April, 2009  

  • I am new to xquery, but I wrote one using stylus studio. I am now trying to run this query using XqUSEme. When I press the preform xquery button nothing happens. No error, output, not even processing time.

    The xquery works with stylus studio, and creates an html output from two xml files.

    Please advise.

    By Blogger RTM, at Wednesday, 01 April, 2009  

  • Hello JD/RTM,

    It is quite possible that there is a problem with the extension or Java at the moment.

    The reason for this is that Java support in Firefox (on which the extension depends) has been a bit in flux, but things should have stabilized by now, and if you are running Windows and have version Java 6 update 12 or higher, you can go to the Addons site and do the following steps to get the latest version which should work.

    First, register there if you do not have an account (you have to register and login to get items in the "sandbox"--extensions that are waiting for approval), then you can go to the XqUSEme page and select "See all Versions". You will then see the "Experimental" 1.4.8 version which you can try installing. I am running Firefox 3.08 (and I've tried it with Firefox 3.1 betas too and it works there as well) on Windows with Java 6 update 13 (it worked on update 12 too, but not earlier).

    If you are using Linux, then even if you're running Java 6 update 12+, the Addons reviewer has told me that it isn't working for him in Ubuntu. Since I don't have a Linux machine to play with, I can't easily do debugging to try to solve the problem, though if you had Linux and were willing to volunteer, you could let me know what if any errors you were getting when you ran it, and I could try changing things in the code to make it work.

    So, to summarize, you should probably get some kind of feedback if the extension is working, so it is probably not your XQuery. I remember the same "nothing happening" problem before (either before I had the latest Java update or before I made 1.4.8), so installing 1.4.8 (if you're on Windows) could solve the problem.

    I'd really, really appreciate you letting me know how it goes for you, if you are able to try it again. I'm happy to try to get it working if at all possible...

    take care!
    Brett

    By Blogger Brett, at Wednesday, 01 April, 2009  

  • I am getting an error now, following the download of the new experimental version.

    I think that the way Stylus Studio creates an xquery is not compatible with your program. Could you look at the way the xml document is referenced in my xquery and tell me if this is the problem that I have to figure out or if it is a problem with the the experimental version.

    It is oddly referenced at the beginning, and then again in "meta information" at the end

    I am just trying to reference a file on my desktop.

    By Blogger RTM, at Thursday, 02 April, 2009  

  • Hi,

    Good to hear there's at least an error now. :)

    Happy to look at your XQuery/XML/error message if you can point me to it! :)

    If you are trying to reference a file on your desktop, you should try it in a file:// URL format, such as file://C:/... (or go to the page and then open XqUSEme). You can also try "file:///" with 3 slashes. I believe two is the valid way, but some browsers seem to show/use 3.

    I don't think it will work in XqUSEme if you just reference it with "C:\..."

    Anyhow, the safest way to confirm the general form of XQuery is working is to load the XML file into the current tab in Firefox, then open XqSUEme, and then reference that current file by "doc()" (with nothing inside the parentheses). If the XQuery works in that way, you can then more confidently try to change to doc('file://...'), etc.

    Hope that helps!

    By Blogger Brett, at Thursday, 02 April, 2009  

  • I used this with success on Firefox 2 (windows xp). Now with Firefox 3.0.10 the plugin does not do anything. No error, no result. Nothing at all. I tried your example. Push the "perform Xquery" button, and nothing.

    By Blogger Timothy, at Wednesday, 06 May, 2009  

  • Yes, I'm very sorry but Java support (upon which this extension depends) has gone through some big (though good) changes, so you need to use the latest version which hasn't been released yet (and you must have Jave 6 update 12 or higher (now at update 13)).

    If you go to https://addons.mozilla.org/en-US/firefox/addons/versions/5515 and choose the latest version 1.4.9, it should work fine in Windows (it does for me). It's taking a while to get approved, as I was hoping to fix a problem both with support in Linux as well as when using Firefox 3.5b4 (still not sure if it is my fault or Firefox's), but things do work fine in Firefox 3.0.10, and I hope they will approve it soon (but again, you can download it now, realizing that it has not gone through the full review process yet--they have a backlog of 96 extensions or so).

    If you can't upgrade your Java for some reason, you can also go to the versions page above to go back to version 1.4.7 and just choose not to update.

    Sorry for the troubles...

    By Blogger Brett, at Wednesday, 06 May, 2009  

  • By the way, the approval process is mostly about security issues (since Firefox extensions have high privileges on your system to write to files, etc.) and to ensure that the extension actually works, but I can assure you my new version doesn't make any major changes or security-related ones--for Windows, it was only being held up for crashing on Firefox close in FF3.5b4, though I've asked for it to be approved now for 3.0.10. The changes are just for the Java change and a little clean-up (though I did remove BDBXML support in the latest version as there seemed to be an interaction problem with the latest BDBXML and/or Firefox--you can still of course use the built-in Saxon-B though).

    But if you don't trust me, you can check the source code online or just wait for the approved version... :)

    I appreciate your patience, and also any feedback, positive or negative, you may have along the way...

    Best wishes, Brett

    By Blogger Brett, at Wednesday, 06 May, 2009  

  • Thanks Brett.
    for the record, I was at 1.4.7 of xquseme in firefox 3.0.1 with Java 6 13, and that is what did not work.

    I tried moving down a few versions of xquseme, to no avail.

    Then upgraded to 1.4.9 and now it works fine.

    By Blogger Timothy, at Monday, 11 May, 2009  

Post a Comment

Links to this post:

Create a Link

<< Home


Google
 
Brett's Blog Web