[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: XLST Processors that support JavaScript

Subject: RE: XLST Processors that support JavaScript
From: "Kirk Allen Evans" <kaevans@xxxxxxxxxxxxx>
Date: Wed, 4 Sep 2002 18:21:40 -0400
int.parse javascript
> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx [mailto:owner-xsl-
> list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Eric Promislow
> Sent: Wednesday, September 04, 2002 1:25 PM
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE:  XLST Processors that support JavaScript
> 
> Kirk, the other issue here is how to access the MS XPath
> extensions derfined in MSXML 4.0.  
<snip>
> I can't figure out how to access this namespace without writing a
> .net wrapper class around MSXML 4.   Is there a way of doing this
> inside System.Xml.Xsl XSLT?

I was watching the related thread on visual-xslt-discuss regarding
support for the msxsl:format-date extension in .NET.  

The extension functions defined in urn:schemas-microsoft-com:xslt are
not supported in .NET, they are only supported in MSXML 4.0, as noted in
my post at Microsoft.public.dotnet.xml [1].  This was confirmed as well
by Chris Lovett and Dare Obasanjo, both of Microsoft.  

The workaround recommendation from most people on this mailing list
would be not to use extensions, favoring an XSLT solution.  A good
reference is the datetime_lib.xsl functions from Marrowsoft's Xselerator
(Dimitre:  does FXSL support a date library now?)  

That said, you can still use C# extensions, and you don't have to resort
to using extension objects with XsltArgumentList:  Since .NET's XSLT
parser supports C#, you can use some of the .NET framework classes
directly in conjunction with the msxsl:script element.  Agreed that the
msxsl:format-date function is easier to manage than the System.DateTime
approach, using inline extensions seems to help simplify the solution
somewhat (although I would prefer the ability to debug compiled objects
rather than rely on an external debugger, even though VisualXSLT rocks)
).  

If they don't want to inline the extension, they can use an XSLT include
or import to pull the vendor-specific stuff in (or hide it and make it
easier to work with).  I would have named the function "format-date" for
consistency, but C# balked at that name.  I posted the stylesheet to be
imported at my web site (URL in the stylesheet below) to show a working
demonstration:

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 	
	xmlns:foo="urn:schemas-xmlandasp-net:xslt">

	<xsl:import href="http://www.xmlandasp.net/msxslext.xslt"/>
	
	<xsl:template match="/">
		<h1>user:FormatDate</h1>		
		<xsl:value-of
select="foo:formatdate('1996-08-01','MMMM')"/>		
	</xsl:template>
</xsl:stylesheet>

Here is what the combined stylesheet (including import) really looks
like, should they choose to use a local copy instead of pulling from a
remote server.

<?xml version="1.0" encoding="UTF-8" ?>
<xsl:stylesheet version="1.0" 
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
	xmlns:msxsl="urn:schemas-microsoft-com:xslt" 
	xmlns:user="urn:schemas-xmlandasp-net:xslt">
	<msxsl:script language="C#" implements-prefix="user">
		string formatdate(string wholeDate,string format)
		{
			string yearPart = wholeDate.Substring(0,4);
			string monthPart = wholeDate.Substring(5,2);
			string dayPart = wholeDate.Substring(8,2);
			DateTime mydate = new
DateTime(int.Parse(yearPart),int.Parse(monthPart),int.Parse(dayPart));
			
			return(mydate.ToString(format));
		}
	</msxsl:script>
	<xsl:template match="/">
		<h1>user:formatDate</h1>
		<xsl:value-of
select="user:formatdate('1996-08-01','MMMM')" />
	</xsl:template>
</xsl:stylesheet>


[1]
http://groups.google.com/groups?q=evans+date+xslt&hl=en&lr=&ie=UTF-8&oe=
UTF-8&selm=eJLf8BJ7BHA.2464%40tkmsftngp05&rnum=2

Kirk Allen Evans
http://www.xmlandasp.net
Author, "XML And ASP.NET", New Riders Publishing
http://www.amazon.com/exec/obidos/ASIN/073571200X



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.