Hi David,

That is an error in the documentation. The parameter to xdmp:unpath must be of 
the form returned by xdmp:path.  Generally, the form  starts with the doc 
function, has child XPath steps, and has positional predicates that are 
numbers.  There may be some other forms that work, but unless it is something 
that xdmp:path returns, it is not guaranteed to work (and you have indeed found 
some forms that won't work).

Sorry for the confusion.  We'll get the doc corrected.

Thanks,
-Danny

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of David Sewell
Sent: Monday, July 20, 2009 6:28 PM
To: General XQZone Discussion
Subject: [MarkLogic Dev General] Formal rules for xdmp:unpath() arguments?

The API documentation for xdmp:unpath()

http://developer.marklogic.com/pubs/4.1/apidocs/Extension.html#xdmp:unpath

claim that "any valid XPath expression (represented as a string) is a 
valid input to xdmp:unpath". However, this is clearly not the case, as 
it seems xdmp:unpath() is limited in the type of XPath predicate it can 
accept.

Given a document /test.xml:

   <doc>
     <p n="1">par 1</p>
     <p n="2">par 2</p>
   </doc>

then xdmp:unpath('doc("/test.xml")//p') returns both <p> elements, and 
xdmp:unpath('doc("/test.xml")//p[2]') returns the second one. But all of 
these expressions return "Invalid format for unpath":

xdmp:unpath('doc("/test.xml")//p[last()]')
xdmp:unpath('doc("/test.xml")//p[position() eq 2]')
xdmp:unpath('doc("/test.xml")//p...@n]')
xdmp:unpath('doc("/test.xml")//p[true()]')

This is highly unintuitive. It seems that in fact the only syntax that 
xdmp:unpath() will accept is the syntax produced by an xdmp:path() 
expression, but the documentation doesn't say that.

David

-- 
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