[xquery-talk] Fuctions and variables in replacement string of fn:replace()

David Sewell dsewell at virginia.edu
Tue Apr 30 20:01:01 PDT 2013


When using fn:replace(), is it kosher or illegal to construct the
replacement string dynamically using a function? In some cases this
seems to work (tested in Saxon and MarkLogic):

xquery version "1.0";
let $string := "Now, let's SEND OUT for QUICHE!!"
let $match := "[A-Z][A-Z]+"
return replace($string, $match, concat("$0","$0"))
==> Now, let's SENDSEND OUTOUT for QUICHEQUICHE!!

but in other cases it doesn't. For example, lower-case("$0") has no
effect. And substring("$0", 1, 1) throws an error.

DS

-- 
David Sewell, Editorial and Technical Manager
ROTUNDA, The University of Virginia Press
PO Box 400314, Charlottesville, VA 22904-4314 USA
Email: dsewell at virginia.edu   Tel: +1 434 924 9973
Web: http://rotunda.upress.virginia.edu/


More information about the talk mailing list