Hi,

 

I am currently working with the new XSLT streaming feature in Saxon 9 using the .Net client.

 

I can get a regular transform working fine, but as soon as I add the saxon:stream() call to any XPath in my XSLT I get the following exception when calling the Compile() method on the XSLTCompiler. (I’ve attached my XSLT and .Net code below)

 

“javax.xml.transform.TransformerConfigurationException was unhandled

  Message="Failed to compile stylesheet. 1 error detected."

  Source="saxon9"

  StackTrace:

       at net.sf.saxon.PreparedStylesheet.prepare(Source styleSource)

       at net.sf.saxon.TransformerFactoryImpl.newTemplates(Source source, CompilerInfo info)

       at Saxon.Api.XsltCompiler.Compile(Stream input)

       at SaxonXSLTClient.Transformer.Transform(String sourcePath, String xsltPath) in C:\Projects\InnovationChallenge\SaxonXSLTClient\Transformer.cs:line 26

       at SaxonXSLT.Main.btnTransform_Click(Object sender, EventArgs e) in C:\Projects\InnovationChallenge\SaxonXSLT\Main.cs:line 23

       at System.Windows.Forms.Control.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnClick(EventArgs e)

       at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)

       at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)

       at System.Windows.Forms.Control.WndProc(Message& m)

       at System.Windows.Forms.ButtonBase.WndProc(Message& m)

       at System.Windows.Forms.Button.WndProc(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)

       at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)

       at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

       at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)

       at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)

       at System.Windows.Forms.Application.Run(Form mainForm)

       at SaxonXSLT.Program.Main() in C:\Projects\InnovationChallenge\SaxonXSLT\Program.cs:line 18

       at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)

       at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)

       at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()

       at System.Threading.ThreadHelper.ThreadStart_Context(Object state)

       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)

       at System.Threading.ThreadHelper.ThreadStart()

  InnerException:”

 

XSLT

 

<?xml version="1.0" encoding="utf-8"?>

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" xmlns:saxon="http://saxon.sf.net/">

                <xsl:output method="xml" encoding="UTF-8" indent="yes"/>

 

                <xsl:template match="saxon:stream(doc('input.xml')/">

                                <xsl:text>Hello from streamed query</xsl:text>

                </xsl:template>

 

</xsl:stylesheet>

 

 

.Net Client Code

 

        public void Transform(string sourcePath, string xsltPath)

        {

            Processor processor = new Processor(true);

 

            DocumentBuilder docBuilder = processor.NewDocumentBuilder();

 

            docBuilder.BaseUri = new Uri("http://test");

 

            XdmNode input = docBuilder.Build((new FileStream(sourcePath, FileMode.Open)));

 

            XsltTransformer transformer = processor.NewXsltCompiler().Compile(new FileStream(xsltPath, FileMode.Open)).Load();

 

            transformer.InitialContextNode = input;

 

            transformer.BaseOutputUri = new Uri("http://test");

 

            Serializer serializer = new Serializer();

 

            serializer.SetOutputFile("result.xml");

 

            transformer.Run(serializer);       

        }

 

Any advice on this would be greatly appreciated.