Hi David,

Yes, that is correct, you cannot pass a sequence as the value of an
external variable.  As you surmised, the way to do that is to wrap the
sequence values in XML and pass the node.  Then you can use XPath to get
the values from the node.

Also, you can pass as many external variables as you need.  They just
need to be an even-length sequence alternating between QNames and items.
For example, the following returns (1,2,3):

xdmp:eval("define variable $a as xs:integer external
define variable $b as xs:integer external
define variable $c as xs:integer external

$a, $b, $c", (xs:QName("a"), 1, xs:QName("b"), 2, xs:QName("c"), 3))

Similarly, the following is how you might use a node to do something
similar:

xdmp:eval("define variable $a as node() external

$a//a/text()", (xs:QName("a"), <foo><a>1</a><a>2</a><a>3</a></foo>))

I hope that helps to clarify.
-Danny


-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of David
Sewell
Sent: Thursday, November 29, 2007 7:22 AM
To: General XQZone Discussion
Subject: [MarkLogic Dev General] Passing sequence as variable to
xdmp:eval()?

Is there a way to pass a sequence rather than a node or atomic value as
an external variable to xdmp:eval()?

This works, returning '9' as output:

        define variable $sequence as xs:integer* { (9) }
        xdmp:eval(
           'define variable $seq as xs:integer* external
           $seq',
           (xs:QName("seq"), $sequence)
        )

but this produces an XDMP-ARG error

        define variable $sequence as xs:integer* { (9, 11) }
        xdmp:eval(
           'define variable $seq as xs:integer* external
           $seq',
           (xs:QName("seq"), $sequence)
        )

because the second argument to xdmp:eval is parsed as

  (xs:QName("seq"), 9, 11)

when $sequence is flattened.

Is the only option in a case like this to wrap my sequence of integers
in a constructed XML element and pass that as the external variable to
xdmp:eval(), or am I missing something obvious?

-- 
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 801079, Charlottesville, VA 22904-4318 USA
Courier: 310 Old Ivy Way, Suite 302, Charlottesville VA 22903
Email: [EMAIL PROTECTED]   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to