That's cool and I'll definitely try it at home (Firefox is "locked" at
I'm a complete newbie to Firefox Add-Ons technology, but couldn't your
add-on become a way to do XSLT2.0 on a browser ?
Yes, all of the above, with it currently opening a new window. I might
later give an option to have it open in a new tab/area and/or add a
code output window.
Let me rephrase what I understand your add-on does, and correct me if I'm
- By default, read the current loaded document
- Reformat it to "proper" XML (through Firefox DOM)
- Open a windows to browse to a XSL file (or paste if)
- Do the transformation (thanks to Saxon B)
- Display the result on Firefox (same window as original document ? another
I also do a little extra clean-up that the DOM representation
doesn't--for example, <!----- is allowed in the DOM but not in XML.
One interesting thing I discovered was that certain prominent sites
must be deliberately mangling their code for such reasons, though it
wasn't too difficult to write some regular expressions to fix such
cases like this as I found.
Yes, it is possible to be triggered on a new page load, and should be
possible to do it as you describe. I don't know how much it will slow
things down, but that behavior could also be turned off via the
extension as well. If the XML file had an XSL 1.0 file attached,
Firefox already processed it (thus eliminating the processing
instruction), unless I were to grab the code before processing, which I
am told by another extension developer (whose extension uses the
document's code before DOM processing) who I asked about this, is
significantly harder to do, but since at least a big reason to use the
extension would be access to XSLT version 2.0, the loss of the ability
to use Saxon on 1.0 live-loaded documents shouldn't matter quite as
much, especially since this is not a native component we're adding to
Firefox here (if I could, I'd do that).
So, if your add-on can be triggered when the file is read from the internet
(that's the part I don't know if it is possible with add-ons) you could:
- If the file is kind of XML, check for a Processing Instruction XSL
Stylesheet (otherwise do nothing, it's probably HTML, JPG,...)
- If the processing instruction is found open that file as XSL (otherwise
- If the stylesheet says version="2.0" then invoke Saxon-B for the
transformation and display result in place of XML document being loaded
(otherwise do nothing, Firefox will invoke Tranformiix to transform the
version="1.0", or display a bug if version is incorrect)
However, I just noticed that Firefox also gives an error (and loses the
when the document attaches a stylesheet with type "application/xml" or
"text/xsl", but preserves the DOM and just ignores the processing
instruction if it is of the newer type XSLT 2.0 introduced,
application/xslt+xml . So, while we have an easier (albeit presumably
not fail-safe) means of guessing the version, unfortunately, again,
retrieving the preprocessed code (which we'd need to do with the
just-mentioned older content type references for XSL) is I'm told
significantly harder to do. But that might be as big of a loss if most
people are using application/xslt+xml for 2.0...
If I understand you correctly, the current behavior in Firefox is to
transform files (as I guess you mean) only for XHTML served as such,
since otherwise, it is just treated as HTML "tag soup" and is not
transformed (though internally it is converted to a DOM representation
which is almost well-formed XML). I could detect application/xhtml+xml
differently from application/xml, text/xml, etc. though, but maybe some
would like to use XSLT 2.0 on XHTML as well.
Essentially it is doing automatically what you do manually with your tool
if you let the XML be displayed (although Firefox might display an error in
that case as it does not handle XSLT2.0), and paste the XSL linked in the
processing instruction of the XML loaded.
Of course that would be the default behaviour, and is not in contradiction
with current behaviour to transform HTML files.
Let's discuss any specific further details of the extension &
Firefox off list, unless the issues would be of wider interest to Saxon
Date: Sat, 09 Feb 2008 19:41:48 +0800
From: Brett Zamir <firstname.lastname@example.org>
Subject: [saxon] XSL Results Firefox extension
To: Mailing list for SAXON XSLT queries
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
I thought I'd let you know that a new version of my Firefox extension,
XSL Results, now supports XSLT 2.0, via Saxon-B. You can install it at
https://addons.mozilla.org/en-US/firefox/addon/5023 As with my XQuery
extension, it can auto-convert the HTML of the current document into a
well-formed document before giving the option to apply a stylesheet. Any
feedback is welcome (you can respond personally to me at
email@example.com )... Thanks to Michael for the open source code that
makes this very simple (but hopefully convenient) wrapper possible...
I'd like to make the XSLT 2.0 and XQuery API's available to any Firefox
extension, but due to a bug in Firefox
(https://bugzilla.mozilla.org/show_bug.cgi?id=391642 -- feel free to
vote on it if you like), implementing this as such a component is a bit
harder (at least as far as my current knowledge goes)...
This message and any attachments (the "message") is
intended solely for the addressees and is confidential.
If you receive this message in error, please delete it and
immediately notify the sender. Any use not in accord with
its purpose, any dissemination or disclosure, either whole
or partial, is prohibited except formal approval. The internet
can not guarantee the integrity of this message.
BNP PARIBAS (and its subsidiaries) shall (will) not
therefore be liable for the message if modified.
Do not print this message unless it is necessary,
consider the environment.
Ce message et toutes les pieces jointes (ci-apres le
"message") sont etablis a l'intention exclusive de ses
destinataires et sont confidentiels. Si vous recevez ce
message par erreur, merci de le detruire et d'en avertir
immediatement l'expediteur. Toute utilisation de ce
message non conforme a sa destination, toute diffusion
ou toute publication, totale ou partielle, est interdite, sauf
autorisation expresse. L'internet ne permettant pas
d'assurer l'integrite de ce message, BNP PARIBAS (et ses
filiales) decline(nt) toute responsabilite au titre de ce
message, dans l'hypothese ou il aurait ete modifie.
N'imprimez ce message que si necessaire,
pensez a l'environnement.
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
saxon-help mailing list archived at http://saxon.markmail.org/