Project

Profile

Help

Support #4392

closed

S9API and JSON input

Added by Gerben Abbink over 4 years ago. Updated over 4 years ago.

Status:
Closed
Priority:
Low
Assignee:
Category:
-
Sprint/Milestone:
-
Start date:
2019-11-22
Due date:
% Done:

0%

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

Description

I am using the S9API to evaluate XPath expressions, like this:

Processor processor = new Processor();
XPathCompiler compiler = processor.newXPathCompiler();
XPathExecutable executable = compiler.compile(XPATH_EXPRESSION);
XPathSelector selector = executable.load();
selector.setContextItem(node);
selector.setURIResolver(URI_RESOLVER);
selector.evaluate();

The resolver URI_RESOLVER is used to resolve URLs in function fn:doc(), for instance:

doc("http://www.bbc.co.uk/news_sitemap.xml")//*

So far so good.

Now, i am trying to parse JSON expressions. This works:

...
XPathExecutable executable = compiler.compile("json-doc('http://api.open-notify.org/iss-now.json')" + JSON_EXPRESSION);
...

I have two questions:

  • The resolver URI_RESOLVER is not used to resolve URLs in fn:json-doc(). Is this a bug?
  • My solution works but it is a bit clumsy: is there a way to evaluate JSON expressions without the json-doc() function? I tried ParseJsonFn.parse(), but the resulting Item was not accepted by setContextItem().

Please register to edit this issue

Also available in: Atom PDF