Project

Profile

Help

Unhandled exception Saxon.Hej.trans.UncheckedXPathException

Added by Martin Honnen over 2 years ago

Trying to use SaxonCS with C# code using a compiled XPath expression of the form serialize($value, $map) I get an error

Saxon.Hej.trans.UncheckedXPathException
  HResult=0x80131500
  Nachricht = 
  Quelle = SaxonCS
  Stapelüberwachung:
   at Saxon.Hej.om.SequenceTool.supply(SequenceIterator iter, ItemConsumer`1 consumer)
   at Saxon.Hej.event.SequenceCopier.copySequence(SequenceIterator in, Receiver out)
   at Saxon.Hej.functions.Serialize.evalSerialize(SequenceIterator iter, Item param, XPathContext context)
   at Saxon.Hej.functions.Serialize.call(XPathContext context, Sequence[] arguments)
   at Saxon.Hej.expr.FunctionCall.iterate(XPathContext context)
   at Saxon.Hej.sxpath.XPathExpression.evaluateSingle(XPathDynamicContext context)
   at Saxon.Hej.s9api.XPathSelector.evaluateSingle()
   at Saxon.Api.XPathSelector.EvaluateSingle()
   at SaxonCSUncheckedXPathExceptionExample.Program.Main(String[] args) in C:\Users\marti\source\repos\SaxonCSUncheckedXPathExceptionExample\Program.cs:line 23

  Diese Ausnahme wurde ursprünglich von dieser Aufrufliste ausgelöst:
    [Externer Code]

Innere Ausnahme 1:
XPathException: Cannot serialize a map using this output method

Shouldn't this be thrown to C# and my code from the EvaluateSingle as an SaxonApiException?

Minimal code:

            var processor = new Processor();

            var xpathCompiler = processor.NewXPathCompiler();

            xpathCompiler.DeclareVariable(new QName("value"));
            xpathCompiler.DeclareVariable(new QName("serialization-params"));

            var xpathExpression = xpathCompiler.Compile("serialize($value, $serialization-params)").Load();

            xpathExpression.SetVariable(new QName("value"), new XdmMap());
            xpathExpression.SetVariable(new QName("serialization-params"), XdmMap.MakeMap(new Dictionary<string, string>() { { "method", "xml" } }));

            var result = xpathExpression.EvaluateSingle();

            Console.WriteLine(result.StringValue);

    (1-1/1)

    Please register to reply