xsl-list
[Top] [All Lists]

RE: [xsl] saxon to .net exslt problem

2007-11-05 10:54:33
From: Don Smith [mailto:dsmith_lockesmith(_at_)yahoo(_dot_)com] 
Sent: 05 November, 2007 12:08
To: XSLT
Subject: [xsl] saxon to .net exslt problem

I've developed an 1.0 transformation using the Saxon Java 
engine. It uses the date() function from the exslt library. 
Everything works fine.

We're now trying to move this to a .NET 2.0 environment. 

This code snippet:

System.Xml.Xsl.XslCompiledTransform xsl = new 
System.Xml.Xsl.XslCompiledTransform();
xsl.Load(xsltPath);
xsl.Transform(xmlPath, htmlPath); // THIS LINE THROWS AN ERROR

throws this error:

System.Xml.Xsl.XslTransformException: Cannot find the script 
or external object that implements prefix 
'http://exslt.org/dates-and-times'. at. . .(I can include the 
rest of this error message if necessary) 

You probably need to register the extension functions.  The
following code is based on EXSLT.NET (a defunct gotdot.net
project), not Saxon, but the solution is probably similar:

Dim urlResolver As New XmlUrlResolver
Dim xmlDocument As New XmlDocument
Dim xslDocument As New XslTransform
Dim params      As New XsltArgumentList

xmlDocument.Load("file.xml")
xslDocument.Load(xmlDocument, urlResolver, 
[Assembly].GetExecutingAssembly.Evidence)

params.AddExtensionObject(ExsltNamespaces.Common, New ExsltCommon)
params.AddExtensionObject(ExsltNamespaces.DatesAndTimes, New ExsltDatesAndTimes)
params.AddExtensionObject(ExsltNamespaces.Math, New ExsltMath)
params.AddExtensionObject(ExsltNamespaces.Random, New ExsltRandom)
params.AddExtensionObject(ExsltNamespaces.RegularExpressions, New 
ExsltRegularExpressions)
params.AddExtensionObject(ExsltNamespaces.Sets, New ExsltSets)
params.AddExtensionObject(ExsltNamespaces.Strings, New ExsltStrings)
params.AddExtensionObject(ExsltNamespaces.GDNDatesAndTimes, New 
GDNDatesAndTimes)
params.AddExtensionObject(ExsltNamespaces.GDNDynamic, New GDNDynamic)
params.AddExtensionObject(ExsltNamespaces.GDNMath, New GDNMath)
params.AddExtensionObject(ExsltNamespaces.GDNRegularExpressions, New 
GDNRegularExpressions)
params.AddExtensionObject(ExsltNamespaces.GDNSets, New GDNSets)
params.AddExtensionObject(ExsltNamespaces.GDNStrings, New GDNStrings)

xslDocument.Transform(xmlDocument, params, urlResolver)


Andy.

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--

<Prev in Thread] Current Thread [Next in Thread>