RE: [xsl] Evaluating XSLT2 from code

Subject: RE: [xsl] Evaluating XSLT2 from code
From: Andrew Sharpe <andrewrwsharpe@xxxxxxxxx>
Date: Thu, 11 Aug 2005 09:59:46 -0400 (EDT)
Thanks very much Dr. Kay.  As I need to evaluate the
expression from my Dotnet program, I tried your
suggestion using Saxon.NET in C# like so:

using net.sf.saxon;
using net.sf.saxon.query;
using javax.xml.parsers;
using javax.xml.transform.dom;
using org.w3c.dom;

Configuration c = new Configuration();
StaticQueryContext qp = new StaticQueryContext(c);
XQueryExpression xe =
DynamicQueryContext dqc = new DynamicQueryContext(c);
DocumentBuilderFactory f =
DocumentBuilder d = f.newDocumentBuilder();
Document doc = d.parse(new<myxmlfile>));
DocumentInfo di = qp.buildDocument(new
java.util.List result = xe.evaluate(dqc);

but received the all-too familiar :

System.TypeLoadException was unhandled
on type 'net.sf.saxon.value.CalendarValue' from
assembly 'Saxon.NET, Version=, Culture=neutral,
PublicKeyToken=039082bc3d203ffd' is overriding a
method that has been overridden."
       at net.sf.saxon.value.Value.convert(Item item)

I receive this exception quite often in my attempts to
use Saxon.NET.  Their mailing list has proven

If anyone out there is experienced with Saxon.NET and
has suggestions, or anyone has any alternative
suggestions (other than Saxon.NET) to evaluate
"format-date(<myxpath>, '[M]-[D]-[Y]')" against a DOM
in memory from within my Dotnet application, I would
be very much appreciative.

Thanks again,

Andrew Sharpe
Moncton, NB
> -----Original Message-----
>Date: Wed, 10 Aug 2005 18:53:15 +0100
>To: <xsl-list@xxxxxxxxxxxxxxxxxxxxxx>
>From: "Michael Kay" <mike@xxxxxxxxxxxx>
>Subject: RE: [xsl] Evaluating XSLT2 from code

>Saxon provides a mirror of the XSLT format-date() 
>function in the Saxon
>namespace for use in XQuery, so

>declare namespace saxon="";;

>is a valid query and can be executed against a DOM 
>using the Saxon XQuery API. 

>Michael Kay

>> -----Original Message-----
>> From: Andrew Sharpe
>> Sent: 10 August 2005 13:54
>> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
>> Subject: [xsl] Evaluating XSLT2 from code
>> I would like to be able to evaluate XSLT2
>> against a DOM from within Dotnet.  I say XSLT2
>> of XPATH2 because I need to be able to use the new
>> format-date function available in XSLT2 (not part
>> the XPath spec).  I have evaluated other date
>> formatting approaches in XSLT1 and find them to be
>> insufficient for what I need to do.
>> Currently I am going through the painstaking
>> of wrapping the expression in an XSLT2 stylesheet,
>> saving that stylesheet out to disk, and then
>> Saxon8 as a separate command-line process and
>> redicting the standard output of that process to my
>> Dotnet program.  Surely there must be a better way.
>> I have taken a look at Saxon.NET and find it to be
>> great idea but can't get even the simplest of
>> in-memory transformations to work with a DOM. 
>> Examples are almost non-existant and their mailing
>> list has been completely unresponsive.
>> So to simplify, I would like to evaluate
>> "format-date(/sample/path/@date, '[M]-[D]-[Y]')"
>> against a DOM from within my Dotnet application. 
>> ideas at all would be much appreciated.  Thanks in
>> advance,
>> Andrew Sharpe
>> Moncton, NB
>> Canada


Find your next car at

Current Thread