Hi all,
in a Java module I create a "org.w3c.dom.Node" (with java.xml.parsers.DocumentBuilder) and return it to XQuery/BaseX.
Since 10.7 I get this exception:
# schnipp
Exception in thread "main" java.lang.NullPointerException: Cannot invoke "org.basex.util.hash.TokenMap.put(byte[], byte[])" because "nsMap" is null
at org.basex.query.value.node.FElem.build(FElem.java:99)
at org.basex.query.value.type.NodeType$3.cast(NodeType.java:60)
at org.basex.query.value.type.NodeType$3.cast(NodeType.java:55)
at org.basex.query.func.java.JavaCall.toValue(JavaCall.java:262)
at org.basex.query.func.java.DynJavaFunc.eval(DynJavaFunc.java:90)
at org.basex.query.func.java.JavaCall.value(JavaCall.java:81)
at org.basex.query.expr.List.value(List.java:230)
at org.basex.query.expr.gflwor.GFLWOR.value(GFLWOR.java:92)
at org.basex.query.expr.gflwor.Let$LetEval.next(Let.java:146)
at org.basex.query.expr.gflwor.GFLWOR.value(GFLWOR.java:92)
at org.basex.query.expr.Try.value(Try.java:93)
at org.basex.query.expr.List.value(List.java:226)
at org.basex.query.expr.gflwor.GFLWOR.value(GFLWOR.java:92)
at org.basex.query.expr.List.value(List.java:230)
at org.basex.query.expr.If.value(If.java:158)
at org.basex.query.expr.List.value(List.java:230)
at org.basex.query.expr.Try.value(Try.java:93)
at org.basex.query.expr.gflwor.GFLWOR.value(GFLWOR.java:92)
at org.basex.query.expr.If.value(If.java:158)
at org.basex.query.expr.List.value(List.java:226)
at org.basex.query.expr.Try.value(Try.java:93)
at org.basex.query.expr.ParseExpr.iter(ParseExpr.java:46)
at org.basex.query.scope.MainModule.iter(MainModule.java:48)
at org.basex.query.QueryContext.lambda$iter$4(QueryContext.java:357)
at org.basex.query.QueryContext.run(QueryContext.java:766)
at org.basex.query.QueryContext.iter(QueryContext.java:357)
at org.basex.query.QueryProcessor.iter(QueryProcessor.java:95)
# schnapp
Do I have to create the Node differently now, or is this a bug?
nsMap. a map of namespace I guess. In my case the w3c.dom.Node has no namespace.
Thanks a lot
Andreas
Hi Christian,
this one already leads into the error.
# schnipp
public class DomNodeBaseXTest {
public DomNodeBaseXTest() {}
public Node myTestCase() throws ParserConfigurationException {
DocumentBuilderFactory docFactory = DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder = docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument();
Element rootElement = doc.createElement("root");
Element subElement = doc.createElement("leaf");
subElement.setTextContent("myText");
rootElement.appendChild(subElement);
return rootElement;
}
}
# schnapp
Thanks a lot
Andreas
Thanks; a fix is available [1,2].
[1] https://files.basex.org/releases/latest/ [2] https://github.com/BaseXdb/basex/commit/48a17c0cc1664e5fa6d6cf07eb437cd35296...
On Mon, Aug 28, 2023 at 1:12 PM Andreas Hengsbach | nexoma < andreas.hengsbach@nexoma.de> wrote:
Hi Christian,
this one already leads into the error.
# schnipp
public class DomNodeBaseXTest {
public DomNodeBaseXTest() {} public Node myTestCase() throws
ParserConfigurationException {
DocumentBuilderFactory docFactory =
DocumentBuilderFactory.newInstance();
DocumentBuilder docBuilder =
docFactory.newDocumentBuilder();
Document doc = docBuilder.newDocument(); Element rootElement =
doc.createElement("root");
Element subElement =
doc.createElement("leaf");
subElement.setTextContent("myText"); rootElement.appendChild(subElement); return rootElement; }
}
# schnapp
Thanks a lot
Andreas
Hi Christian,
wow, that was lightning fast. 😊
It works like clockwork.
Thanks
Andreas
basex-talk@mailman.uni-konstanz.de