Invisible XML doesn't accept lazy strings
Thursday, 30 October 2025 · 2 messages · last reply 3 Nov 2025
JT
Josef Thorne30 Oct 2025 14:18 #
It seems that the invisible XML function can't accept a lazy string. It causes it to have a casting exception. A workaround I found is to serialize the lazy string before passing it to the function with
fn:serialize's text method.Quoted text · 2 lines
> > let $grammar := file:read-text("basex/data/lcl_grammar.ixml")
return
fn:invisible-xml($grammar)
Full stack trace:
Version: BaseX 11.8
Java: Ubuntu, 21.0.8
OS: Linux, amd64
Stack Trace:java.lang.ClassCastException: class org.basex.query.value.item.StrLazy
cannot be cast to class org.basex.query.value.item.Str
(org.basex.query.value.item.StrLazy and org.basex.query.value.item.Str are
in unnamed module of loader 'app')
at
org.basex.query.func.fn.FnInvisibleXml$Generator.generate(FnInvisibleXml.java:72)
at org.basex.query.func.fn.FnInvisibleXml.item(FnInvisibleXml.java:51)
at org.basex.query.func.fn.FnInvisibleXml.item(FnInvisibleXml.java:32)
at org.basex.query.expr.ParseExpr.value(ParseExpr.java:54)
at org.basex.query.expr.ParseExpr.iter(ParseExpr.java:49)
at org.basex.query.expr.Pipeline$1.next(Pipeline.java:66)
at org.basex.query.scope.MainModule$1.next(MainModule.java:65)
at org.basex.query.QueryContext.next(QueryContext.java:387)
at org.basex.query.QueryContext.lambda$cache$6(QueryContext.java:599)
at org.basex.query.QueryContext.run(QueryContext.java:738)
at org.basex.query.QueryContext.cache(QueryContext.java:579)
at org.basex.query.QueryProcessor.cache(QueryProcessor.java:120)
at org.basex.core.cmd.AQuery.run(AQuery.java:82)
at org.basex.core.Command.run(Command.java:233)
at org.basex.core.Command.execute(Command.java:93)
at org.basex.gui.GUI.execute(GUI.java:430)
at org.basex.gui.GUI.lambda$execute$5(GUI.java:375)
at java.base/java.lang.Thread.run(Thread.java:1583)CG
Christian Grün3 Nov 2025 11:20 #
Thanks for the observation; the problem has been fixed [1]. BaseX 12.1 will be released later this month.
Best,
Christian
[1] https://files.basex.org/releases/latest/
Quoted text · Josef Thorne · 31 lines
Von: Josef Thorne via BaseX-Talk <basex-talk at mailman.uni-konstanz.de> Gesendet: Donnerstag, 30. Oktober 2025 14:17 An: basex-talk at mailman.uni-konstanz.de <basex-talk at mailman.uni-konstanz.de> Betreff: [basex-talk] Invisible XML doesn't accept lazy strings It seems that the invisible XML function can't accept a lazy string. It causes it to have a casting exception. A workaround I found is to serialize the lazy string before passing it to the function with fn:serialize's text method. let $grammar := file:read-text("basex/data/lcl_grammar.ixml") return fn:invisible-xml($grammar) Full stack trace: Version: BaseX 11.8 Java: Ubuntu, 21.0.8 OS: Linux, amd64 Stack Trace: java.lang.ClassCastException: class org.basex.query.value.item.StrLazy cannot be cast to class org.basex.query.value.item.Str (org.basex.query.value.item.StrLazy and org.basex.query.value.item.Str are in unnamed module of loader 'app') at org.basex.query.func.fn.FnInvisibleXml$Generator.generate(FnInvisibleXml.java:72) at org.basex.query.func.fn.FnInvisibleXml.item(FnInvisibleXml.java:51) at org.basex.query.func.fn.FnInvisibleXml.item(FnInvisibleXml.java:32) at org.basex.query.expr.ParseExpr.value(ParseExpr.java:54) at org.basex.query.expr.ParseExpr.iter(ParseExpr.java:49) at org.basex.query.expr.Pipeline$1.next(Pipeline.java:66) at org.basex.query.scope.MainModule$1.next(MainModule.java:65) at org.basex.query.QueryContext.next(QueryContext.java:387) at org.basex.query.QueryContext.lambda$cache$6(QueryContext.java:599) at org.basex.query.QueryContext.run(QueryContext.java:738) at org.basex.query.QueryContext.cache(QueryContext.java:579) at org.basex.query.QueryProcessor.cache(QueryProcessor.java:120) at org.basex.core.cmd.AQuery.run(AQuery.java:82) at org.basex.core.Command.run(Command.java:233) at org.basex.core.Command.execute(Command.java:93) at org.basex.gui.GUI.execute(GUI.java:430) at org.basex.gui.GUI.lambda$execute$5(GUI.java:375) at java.base/java.lang.Thread.run(Thread.java:1583)
Written for BaseX 12.0. BaseX may have changed since: please check the current documentation.
⚡Generated with XQuery