RE: [xsl] Evaluating XSLT2 from code

Subject: RE: [xsl] Evaluating XSLT2 from code
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Fri, 12 Aug 2005 00:01:12 +0100
Please be aware that I don't support Saxon.NET - it's produced quite
independently of myself or my company Saxonica.

Michael Kay
http://www.saxonica.com/ 

> -----Original Message-----
> From: Andrew Sharpe [mailto:andrewrwsharpe@xxxxxxxxx] 
> Sent: 11 August 2005 15:00
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: RE: [xsl] Evaluating XSLT2 from code
> 
> 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 net.sf.saxon.om;
> using javax.xml.parsers;
> using javax.xml.transform.dom;
> using org.w3c.dom;
> 
> Configuration c = new Configuration();
> StaticQueryContext qp = new StaticQueryContext(c);
> qp.declareActiveNamespace("saxon",
> "http://saxon.sf.net/";);
> XQueryExpression xe =
> qp.compileQuery("format-date(<myxpath>,
> '[M]-[D]-[Y]')");
> DynamicQueryContext dqc = new DynamicQueryContext(c);
> DocumentBuilderFactory f =
> DocumentBuilderFactory.newInstance();
> DocumentBuilder d = f.newDocumentBuilder();
> Document doc = d.parse(new java.io.File(<myxmlfile>));
> DocumentInfo di = qp.buildDocument(new
> DOMSource(doc));
> dqc.setContextNode(di);
> java.util.List result = xe.evaluate(dqc);
> 
> but received the all-too familiar :
> 
> System.TypeLoadException was unhandled
>   Message="Method
> 'java.lang.Comparable/compareTo(Ljava.lang.Object;)I'
> on type 'net.sf.saxon.value.CalendarValue' from
> assembly 'Saxon.NET, Version=0.2.8.3, Culture=neutral,
> PublicKeyToken=039082bc3d203ffd' is overriding a
> method that has been overridden."
>   Source="Saxon.NET"
>   TypeName="net.sf.saxon.value.CalendarValue"
>   StackTrace:
>        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
> unresponsive.
> 
> 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
> Canada
>  
> > -----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="http://saxon.sf.net/";;
> >saxon:format-date(....)
> 
> >is a valid query and can be executed against a DOM 
> >using the Saxon XQuery API. 
> 
> >Michael Kay
> >http://www.saxonica.com/
> 
> >> -----Original Message-----
> >> From: Andrew Sharpe
> [mailto:andrewrwsharpe@xxxxxxxxx] 
> >> 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
> expressions
> >> against a DOM from within Dotnet.  I say XSLT2
> nstead
> >> of XPATH2 because I need to be able to use the new
> >> format-date function available in XSLT2 (not part
> of
> >> 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
> process
> >> of wrapping the expression in an XSLT2 stylesheet,
> >> saving that stylesheet out to disk, and then
> executing
> >> 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
> a
> >> 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. 
> Any
> >> ideas at all would be much appreciated.  Thanks in
> >> advance,
> >> 
> >> Andrew Sharpe
> >> Moncton, NB
> >> Canada
> 
> 
> 	
> 
> 	
> 		
> __________________________________________________________ 
> Find your next car at http://autos.yahoo.ca

Current Thread