Bug #4299
closedSaxon-HE v9.9.1.4 Exception XPDY0002 running .NET C# test example XsltSimple1.
100%
Description
Saxon-HE v9.9.1.4 Exception XPDY0002 running .NET C# test example XsltSimple1.
I am using Saxon API for .NET (Saxon-HE v9.9.1.4 version). I am testing on Windows 10 Enterprise 1809 with Visual Studio Professional 2019 version 16.2.0.
I made a Windows console program with .NET 4.7.2 runtime using the ExamplesHE.cs source code unmodified. I also used the books.xml and books.xsl files unmodified. Then I set the project startup parameters in the debugger to run the XsltSimple1 test:
// Relevant code fragment:
// ------------------------------------------------------------------
public override void run(Uri samplesDir) // running XsltSimple1 test
{
// Create a Processor instance.
Processor processor = new Processor();
// Load the source document
XdmNode input = processor.NewDocumentBuilder().Build(new Uri(samplesDir, "data/books.xml"));
// Create a transformer for the stylesheet.
Xslt30Transformer transformer = processor.NewXsltCompiler().Compile(new Uri(samplesDir, "styles/books.xsl")).Load30();
// Create a serializer, with output to the standard output stream
Serializer serializer = processor.NewSerializer();
serializer.SetOutputWriter(Console.Out);
// Transform the source XML and serialize the result document
transformer.ApplyTemplates(input, serializer); // XPDY0002 exception here
}
}
// End of code fragment
// ------------------------------------------------------------------
Error detail.
Data {System.Collections.ListDictionaryInternal}
ErrorCode {err:XPDY0002}
Hresult -2146233088
HelpLink null
InnerException null
IsTypeError false
LineNumber 10
Message = "The context item for axis step root/descendant::CATEGORY is absent"
ModuleUri = "file:///c:/mittN...august/SaxonHETestData/styles/books.xsl"
Source "saxon9he-api"
StackTrace = " at Saxon.Api.Xslt30Transformer.ApplyTemplates(XdmValue selection, XmlDestination destination)\r\n at SaxonHE.XsltSimple1.run(Uri samplesDir) in C:\\mittN1Reikn\\Test21august\\SaxonHETest\\Program.cs:line 460\r\n at SaxonHE.ExamplesHE.Main(String[] a...
TargetSite = {Void ApplyTemplates(Saxon.Api.XdmValue, Saxon.Api.XmlDestination)}
UnderlyingException = {"The context item for axis step root/descendant::CATEGORY is absent"}
Can anyone explain what the reason is? I think it is fairly unlikely that there is such a basic bug in the SaxonHE library or the sample files provided. I did have to make the Visual Studio project myself as I did not use the Ant files for building.
Please note that even though I am a programmer with decades of experience, working with XML on occasion, this is my first attempt at performing an XSLT transformation from code. So the error I am getting might be explained by some configuration or setup error. Interestingly the XsltSimple2 test runs without error but the XsltSimple3 fails with the same error. So at least the setup is somewhat working.
When I run the transform.exe command utility provided I get no errors when I run it on the same files as used in XsltSimple1 test.
The test command used was: transform -s:books.xml -xsl:books.xsl -o:booksOut.xml
Please register to edit this issue