There are two new killer but undocumented features in Microsoft .NET 2.0 pertaining to EXSLT. Anybody like me regularly digging in System.Xml assembly probably knows it, but general audience is still unaware. So I want to share these secrets.
...
Secret #1. Unexpected surprise. Microsoft's new XSLT processor (XslCompiledTransform) supports natively two EXSLT extension functions - exsl:node-set() and exsl:object-type(). That is technically speaking XslCompiledTransform supports EXSLT - Common module.
Moreover, as mentioned in the "Introducing XslCompiledTransform" article on the Microsoft XML Team's WebLog, the behaviour of Microsoft specific msxsl:node-set() extension function is aligned with the behavior of the same function in MSXML and exsl:node-set() - when being given something other than RTF it returns text node containing string value of the passed object. As a matter of interest msxsl:node-set() and exsl:node-set() in XslCompiledTransform is the same function.
Now that means that XslCompiledTransform joins Saxon, Xalan, libxslt and other mainstream XSLT processors natively supporting exsl:node-set() function and any XSLT stylesheet using it for manipulating temporary trees is now completely portable between .NET 2.0, Java and other platforms. That's a substantial relief for anybody doing serious XSLT development. And that makes lots of practical sense to keep XML processing portable.
Secret #2. Using XSLT extension objects in .NET 2.0 now doesn't require FullTrust. MSDN documentation says opposite, but this is just a documentation copy-n-paste bug.
This used to be a showstopper problem for using EXSLT.NET in a semi-trusted environments like ASP.NET or ClickOnce and I was complaining about it all the way. Now this isn't a problem anymore and you can use EXSLT extension functions in ASP.NET applications, e.g. via my free eXml Web server control.
That doesn't mean of course that security is compromised in any way. Code Access Security is still in place and XSLT extension functions in .NET 2.0 can only perform what is allowed for the code that runs XSLT transformation. And as 70+ EXSLT.NET functions doesn't do anything dangerous like accessing file system or remote resources, it's safe to use EXSLT.NET functions in ASP.NET even on minimal trust level.
Also don't forget that XSLT extension objects don't come with XSLT stylesheets - they must be passed in code explicitly so they are safe.
That's way cool. I only wonder why such killer features are not documented. I can only guess that this is probably a consequence of the poor Microsoft middle management problem - be these features documented no doubts they would be cut at early stage. Now that .NET 2.0 is out I urge everybody to use exsl:node-set() and exsl:object-type() functions along with eXml Web server control to make it impossible to cut these features anymore :)
We should thank Microsoft XML Team for making it possible even in undocumented way. And we should say thank you to Dare for pushing EXSLT inside Microsoft despite he thinks he didn't succeed:
I know this because I've been in that position trying to get us to implement EXSLT and Schematron when I was on the XML team. Did I succeed? The lack of any implementations of either technology from Microsoft shows I didn't even come close.
You say you know XSLT well? Try answer this quiz of XSLT 1.0 oddities by James Fuller.
...
Subject: [xsl] a bit of distraction ' quiz of XSLT 1.0 oddities'
From: James Fuller
Date: Tue, 27 Dec 2005 11:04:03 +0100
a bit of distraction for those who must work.
I am generating a little 'quiz of oddities' for XSLT 1.0, some of which
I have bumped into from time to time....none are particularly mind
blowing, though some may make one stop and think.
Here are some of mine....(xsl:stylesheet elements have been stripped),
any more good questions out there ? Answers sometime around new years.
--------------------------------------------------------------
Whats the output
XML
1
2
3
4
XSLT
this template
that template
When matching templates are equivelent which one gets matched?
--------------------------------------------------------------
What does the string-length() function return in the following
xml / xslt snippet ?
XML
Testing this
and this too
XSLT
-------------------------------------------------------------
Can a template be both named and match? for example is the following
construction possible?
-------------------------------------------------------------
Does exclude-result-prefixes defined on an xsl:stylesheet element apply
to subtrees included with xsl:include ?
--------------------------------------------------------------
Is there any way of using apply-templates using a mode 'decided' at run
time ?
-------------------------------------------------------------
What does this do?
some text
-------------------------------------------------------------
Can anyone show a clever use of the why one would use the floor()
function specifically in XSLT 1.0 ?
-------------------------------------------------------------
How does one arrive to this xml
doc #1:
http://example.comhttp://test.extension
http://administrator.comhttp://xml.apache.org/xslt/java
http://tester.comhttp://www.w3.org/XML/1998/namespace
doc #2:
http://www.w3.org/XML/1998/namespace
from this xml ?
-------------------------------------------------------------
Is the following a valid declaration for xsl:variable?
--------------------------------------------------------------
Which XSLT processors fully support EXSLT node-set extension ?
--------------------------------------------------------------
When there is no xsl:output element how does an XSLT processor determine
that you want an html result ?
--------------------------------------------------------------
How does FXSL calculate sin() ?
--------------------------------------------------------------
Is there anyway to achieve a conditional inclusion (e.g. conditionally
use xsl:include) ?
--------------------------------------------------------------
I have a few more.....pls send your questions, will compile and perhaps ask DaveP
to include in XSLT FAQ.
cheers, Jim Fuller
This guy Matt Cassell is 15 years old and now he's got C# MVP award. Boy, I feel like a dinosaur now...
...
Almost 2 years ago I published a post "Transforming WordML to HTML: Support for Images" showing how to hack Microsoft WordML2HTML stylesheet to support images. People kept telling me it doesn't support some weird image formats or header images. Moreover I realized it has a bug and didn't work with
...
Starting Word 2003 document with images in body and header:
Magic XSLT transformation:
nxslt2 test.xml wordml2html-.NET-script.xslt -o test.html
produces test.html and a directory containing decoded images:
Download the stylesheet at the XML Lab downloads page. Any comments are welcome.
I've never tried working with natural keyboards. Somehow I thought they are kinda unnatural :) Now I want to give it a try, may be this new Microsoft Natural Ergonomic Keyboard 4000: Seems like people love it. It's great to see the latest Microsoft keyboard with standard 2x3 home/end key
...