Hi,
how can I translate this Java[1] to XQuery according to [2]?
package com.vladsch.flexmark.samples; import com.vladsch.flexmark.util.ast.Node; import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.data.MutableDataSet; public class BasicSample { public static void main(String[] args) { MutableDataSet options = new MutableDataSet(); // uncomment to set optional extensions //options.set(Parser.EXTENSIONS, Arrays.asList(TablesExtension.create(), StrikethroughExtension.create())); // uncomment to convert soft-breaks to hard breaks //options.set(HtmlRenderer.SOFT_BREAK, "<br />\n"); Parser parser = Parser.builder(options).build(); HtmlRenderer renderer = HtmlRenderer.builder(options).build(); // You can re-use parser and renderer instances Node document = parser.parse("This is *Sparta*"); String html = renderer.render(document); // "<p>This is <em>Sparta</em></p>\n" System.out.println(html); } }
I only get so far as to:
declare namespace Node = "com.vladsch.flexmark.util.ast.Node"; declare namespace HtmlRenderer =" com.vladsch.flexmark.html.HtmlRenderer"; declare namespace Parser = "com.vladsch.flexmark.parser.Parser"; declare namespace MutableDataSet = "com.vladsch.flexmark.util.data.MutableDataSet"; declare option db:checkstrings 'false'; let $mds := MutableDataSet:new() let $builder := Parser:builder($mds) return $builder
which results in
DataSet{dataSet={}}
I found no documentation, on how to translate something as
Parser.builder(options).build()
to XQuery. How do I express the method
build()
of the instance
Parser.builder(options)
I just created?
Also, when I try the other way, by importing, for the following code
import module namespace Node = "java:com.vladsch.flexmark.util.ast.Node"; import module namespace HtmlRenderer = "java:com.vladsch.flexmark.html.HtmlRenderer"; import module namespace Parser = "java:com.vladsch.flexmark.parser.Parser"; import module namespace MutableDataSet = "java:com.vladsch.flexmark.util.data.MutableDataSet"; let $mds := MutableDataSet:new()
I get:
[XQST0059] Could not instantiate com.vladsch.flexmark.util.ast.Node: java.lang.InstantiationException.
Could it be, that it is only possible to call static properties via [1]? Am I right, that I need to write wrapper code in Java and then prepare results in a way, that I can retreive them from my own Java class?
Thank you.
[1]: https://github.com/vsch/flexmark-java/blob/master/flexmark-java-samples/src/... [2]: https://docs.basex.org/wiki/Java_Bindings [3]: https://github.com/vsch/flexmark-java