This is the mail archive of the kawa@sources.redhat.com mailing list for the Kawa project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

XQuery repl + "document" not found when loading in Scheme mode (using XQeury from Scheme)


Hi again,

this time, I'm trying to make use of XQuery to transform a foreign XML document.

Problems
1) document function works in repl, not in file??
2) how to make use of the result from another file (in Scheme)?
3) how to create a Scheme list structure from XML?

2) seems simple
#|kawa:13|# ((load "xqltest") ;  xqltest.xql compiled with -C --xquery
#|kawa:14|# (define a (make <xqltest>)
#<procedure>
Invoking (a) yields the XML/multiple-values thing:
#|kawa:14|# (as-xml (a))
<table>
aoh
</table>

Can I call a function defined via
"define function" in a .xql file
from Scheme?
#|kawa:3|# (descendent-or-self "<a>")
<a>
Calling descendent-or-self in Scheme looks a lot like the identity function!?

I used
---------xqltest.xql
define function descendent-or-self ($x) {
  $x, for $z in children($x) return descendent-or-self($z) }
<table>
aoh
</table>
-----------

My idea was to write a XML transformer of a known document using XQuery, then take the result into Scheme where all further processing is done on Scheme data structures.


Ad 1) I get a strange error message:
----------xquerytest.xql
let $result := (document("file:i:/.../foo.xml"))
  return $result
--------------------
Compilation of the .xql file was fine.
>java -classpath h:/.../kawa-1.6.98.jar;. kawa.repl
#|kawa:1|# (load "xquerytest")
gnu.mapping.UnboundSymbol: Unbound symbol document
        at gnu.mapping.Constraint.get(Constraint.java:15)
        at gnu.mapping.Binding.get(Binding.java:25)
        at xquerytest.apply(xquerytest.xql:2)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:239)
        at gnu.mapping.CallContext.run(CallContext.java:283)
        at gnu.expr.ModuleBody.run(ModuleBody.java:43)
        at gnu.expr.ModuleBody.run(ModuleBody.java:29)
        at kawa.standard.load.loadClassFile(load.java:28)
        at kawa.standard.load.apply(load.java:264)
        at kawa.standard.load.apply2(load.java:172)
        at kawa.standard.load.apply1(load.java:162)
        at gnu.mapping.Procedure1.applyN(Procedure1.java:49)
        at gnu.mapping.Procedure.apply(Procedure.java:102)
        at gnu.mapping.CallContext.runUntilDone(CallContext.java:239)
        at gnu.expr.ModuleExp.evalModule(ModuleExp.java:189)
        at kawa.Shell.run(Shell.java:231)
        at kawa.Shell.run(Shell.java:180)
        at kawa.Shell.run(Shell.java:167)
        at kawa.Shell.run(Shell.java:154)
        at kawa.repl.main(repl.java:561)


Furthermore, it seems that the typical #|(---:3|# prompt is lost in the XQuery toplevel.
I can only enter
let $result := (document("file:i:/.../foo.xml")) return $result
in a single line to the terminal, which is quite inconvenient for copy&paste and interactive sessions.

xquery[1]: let $result := (document("file:i:/foo.xml"))
xquery[2]:   return $result
<stdin>:2:1: missing 'return' clause

while
xquery[29]: let $result := document("file:i:/Projekte_ES24/aktuelle_Projekte/Red
akteur/Spezifikation/Pemap-ServiceParams_Example.xml") return $result
yields


<ServiceParams xsi:noNamespaceSchemaLocation=...


3) I call (parse-xml-from-url "file:i:/...Example.xml")
which outputs a (lots of (...))-looking list
But it's just output? Hot to build a list from that, e.g. "pipe" it to the Scheme reader?


Using kawa-1.68 on MS-woes2k with JDK-1.3

Thanks for your helpm,
	Jorg Hohle.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]