Project

Profile

Help

Bug #5883

closed

SaxonCS 11.5 gives System.NullReferenceException: Object reference not set to an instance of an object on using XPath //*:h2[contains(@class, 'foo')] against DOM constructed from saxon:parse-html

Added by Martin Honnen about 1 year ago. Updated 9 months ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
.NET API
Sprint/Milestone:
Start date:
2023-02-16
Due date:
% Done:

100%

Estimated time:
Legacy ID:
Applies to branch:
11
Fix Committed on Branch:
11
Fixed in Maintenance Release:
Platforms:
.NET

Description

I have an HTML document like

<!doctype html>
<html>
  <head>
    <title>Test</title>
  </head>
  <body>
    <h2>h2 1</h2>
    <h2 class=foo>h2 2</h2>
  </body>
</html>

that I try to process with SaxonCS 11.5 query from the command line with e.g. 'C:\Program Files\Saxonica\SaxonCS-11.5\SaxonCS.exe' query -qversion:4.0 -qs:"xquery version '4.0'; saxon:parse-html(unparsed-text('test1.html'))//*:h2[contains(@class, 'foo')]" --allowSyntaxExtensions:on !indent=yes.

That gives a NullReferenceException (after the output of the XML declaration<?xml version="1.0" encoding="UTF-8"?>):

System.NullReferenceException: Object reference not set to an instance of an object.
   at Saxon.Impl.Dom.HtmlNodeWrapper.getAttributeValue(String uri, String local)
   at Saxon.Hej.expr.AttributeGetter.evaluateItem(XPathContext context)
   at Saxon.Hej.expr.AtomicSequenceConverter.evaluateItem(XPathContext context)
   at Saxon.Hej.expr.Expression.evaluateAsString(XPathContext context)
   at Saxon.Hej.functions.Contains.Inner_Optimized_2.effectiveBooleanValue(XPathContext context)
   at Saxon.Hej.expr.FilterIterator.NonNumeric.matches()
   at Saxon.Hej.expr.FilterIterator.getNextMatchingItem()
   at Saxon.Hej.expr.FilterIterator.next()
   at Saxon.Hej.om.SequenceTool.supply(SequenceIterator iter, ItemConsumer`1 consumer)
   at Saxon.Hej.expr.Expression.process(Outputter output, XPathContext context)
   at Saxon.Hej.query.XQueryExpression.run(DynamicQueryContext env, Result result, Properties outputProperties)
   at Saxon.Hej.s9api.XQueryEvaluator.run(Destination destination)
   at Saxon.Hej.Query.runQuery(XQueryExecutable exp, XQueryEvaluator evaluator, Source input, Destination destination)
   at Saxon.Hej.Query.doQuery(String[] args, String command)
Fatal error during query: NullReferenceException: Object reference not set to an instance of an object.
Exiting with code 2

I can't test it directly with 12.0 as that has that (I think known) bug not being able to resolve the file name/relative file path given in -qs.

I will later test in an .xq file with 12.0.

Please register to edit this issue

Also available in: Atom PDF