No Sign Of 'document' Function, But Opera Shows Signs of (E)XSLT Life None-the-Less

by M. David Peterson

From the latest weekly release of Opera (v 9.01 apparently) we discover,

8518,3466,383 - Desktop Team - by Desktop Team

Added support for exls:node-set in XSLT

NOTE: I can only hope that by exls:nose-set, they mean exsl:node-set. If no, then this could does present a problem, but an easily fixed problem, which is always a good thing.

Of course, the ability to combine the document function with the EXSLT node-set() function can be a powerful tool, as this allows the ability to access data that is outside the current context document being processed, to then dice and splice this data into variouses pieces, processing dynamically generated XML fragments via the exsl:node-set function. None-the-less, this (exsl:node-set) is still an EXTREMELY nice addition in which I am truly grateful to the folks at Opera for adding to the XSLT mix.

That said,


Abel Braaksma
2006-09-22 15:17:12
> Opera... Thanks for the exsl:node-set implementation.
Yeah right. Though you seem to hail the corss-browser abilities of using XSLT, this one is not amongst them, considering:

Firefox: not supported. Why? I don't know. They don't provide their own alternative either. In fact, it gives a pretty ugly error:
[Exception... "Component returned failure code: 0x8060000e [nsIXSLTProcessor.transformToDocument]" nsresult: "0x8060000e (<unknown>)" location: "JS frame :: "....

Microsoft has its own extension functions (sounds familiar? JS stories repeat themselves for new standards... alas) and for exslt it will return the following:
Namespace '' does not contain any functions.

So, here we go again. When we want to use something useful, exslt:node-set() in this case, we will need to check the vendor. There it is, bouncing back at you, that stuff you thought you lost when moving from Javascript to XSLT (and still using bits of Javascript). This is what it will look like
<xsl:if test="system-property('xsl:vendor') = 'Opera'">
... you can use exslt:node-set() here....

Opera supporting exslt? Nice gesture, but will be close to useless as long as Firefox, and more specifically, IE, has no normal way of dealing with it.

But I do have another suggestion: using document() the other way in Opera. I haven't tested this myself, but knowing that XSLT is in fact valid XML, you can turn the external document into a XSLT stylesheet, with one large variable. Now you can use the combination of or together with exslt:node-set($yourdoc-variable) to get to your document. For other browsers you can still access the same data, just change your root-XPath a bit.

Ok, there's one glitch that will proof unsurpassable: and cannot be used with AVT (Attribute Value Templates). Hence, the variability of using document() falls back because you have to hardcode your documents for use in Opera (or you have to resort to some sophisticated tricks, which are all well-documented on the xsl-list).

Best wishes,

Abel Braaksma
Nuntia B.V.

2006-11-15 21:30:29

2006-11-16 02:13:39

2006-11-16 13:54:20

2006-11-18 11:11:25

M. David Peterson
2006-11-18 20:14:24

>> using document() the other way in Opera

Which other way would that be? What you are refering to is,

<xsl:variable select="document('')"/>

which would then allow you to reference the transformation file itself.

There's one problem, though: There *IS NO* document() function in Opera.

>> (or you have to resort to some sophisticated tricks, which are all well-documented on the xsl-list). <<

Yeah, I'm aware of XSL-List[ ], but thanks for taking the time to provide the information none-the-less.