Hi,

Not sure about the details of the length (it's hard to look at a
non-reduced example containing a lot of noise), but you pass $piece-of-xml
(or at least a substring of it) as a regex to fn:replace().

So MarkLogic tells you it's not a valid regex, and it looks right to do so.

It's not clear what you want to replace in "aaaa" using the literal XML as
a regex.

Regards,

-- 
Florent Georges
http://fgeorges.org/
http://h2oconsulting.be/


On 22 August 2016 at 12:03, Johan de Boer wrote:

> I am using MarkLogic release 8.0-4 and I get a problem with fn:replace if
> the second argument exceeds a certain length. I use the following script in
> XQuery. This is just a simple query with the only goal to show the error.
>
>
> let $string1 := "aaaa"
> let $string2 := "bbbb"
> let $length-1 := 1463
> let $length-2 := 1464
> let $piece-of-xml := '<change when="2015-01-21" status="created"/><change
> when="2015-09-16" who="9999999999999999999">ABCD EF G</change><change
> when="2015-09-17" who="9999999999999999999">ABCD EF G</change><change
> when="2015-09-22" who="999999999999999999">ABCD EF GH</change><change
> when="2015-10-09" who="9999999999999999999">ABCD EF G</change><change
> when="2016-04-01" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-04-02" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-04-06" who="999999999999999999">ABCD EF GH</change><change
> when="2016-04-09" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-04-10" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-04-18" who="9999999999999999999">Abcd Abcdef</change><change
> when="2016-04-22" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-04-23" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-06-26" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-06-27" who="9999999999999999999">Abcdef
> Abcdefghijk</change><change when="2016-06-28" who="9999999999999999999">Abcdef
> Abcdefghijk</change><change when="2016-07-01"
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-07-02"
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-07-02"
> who="9999999999999999999">Abcdef Abcdefghijk</change><change
> when="2016-07-03" who="9999999999999999999">Abcd Abcdefgh</change><change
> when="2016-07-03" who="9999999999999999999">Abcdef Abcdefghijk</change></
> listChange>'
> let $test1 := fn:substring($piece-of-xml,1,$length-1)
> return fn:replace($string1,$test1,$string2)
>
> This returns the expected value 'aaaa'.
>
> But when I increase the selected length by 1 by replacing:
>
> let $test1 := fn:substring($piece-of-xml,1,$length-1)
>
> by
>
> let $test1 := fn:substring($piece-of-xml,1,$length-2)
>
> I get the error:
> XDMP-REGEX: (err:FORX0002) fn:replace("aaaa", "<change
> when=&quot;2015-01-21&quot; status=&quot;created&quot;/>...", "bbbb") --
> Invalid regular expression The value of $test1 at that point is:
>
> <change when="2015-01-21" status="created"/><change when="2015-09-16" 
> who="9999999999999999999">ABCD EF G</change><change when="2015-09-17" 
> who="9999999999999999999">ABCD EF G</change><change when="2015-09-22" 
> who="999999999999999999">ABCD EF GH</change><change when="2015-10-09" 
> who="9999999999999999999">ABCD EF G</change><change when="2016-04-01" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-02" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-06" 
> who="999999999999999999">ABCD EF GH</change><change when="2016-04-09" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-10" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-18" 
> who="9999999999999999999">Abcd Abcdef</change><change when="2016-04-22" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-04-23" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-06-26" 
> who="9999999999999999999">Abcd Abcdefgh</change><change when="2016-06-27" 
> who="9999999999999999999">Abcdef Abcdefghijk</change><change 
> when="2016-06-28" who="9999999999999999999">Abcdef 
> Abcdefghijk</change><change when="2016-07-01" who="9999999999999999999">Abcd 
> Abcdefgh</change><change when="2016-07-02" who="9999999999999999999">Abcd 
> Abcdefgh</change><change when="2016-07-02" who="9999999999999999999">Abcdef 
> Abcdefghijk</change><change when="2016-07-03" who="9999999999999999999">Abcd 
> Abcdefgh</change><change when="2016-07
>
> Why do I get this error in MarkLogic?
>
>
>
> <http://www.tahzoo.com>
> Johan de Boer
> Developer Java / Developer MarkLogic
> P:  *0031 88 268 2500* <0031%2088%20268%202500>  |  M:
> *0031 6 444 22 758* <0031%206%20444%2022%20758>
> E:  *johan.de.b...@tahzoo.com* <johan.de.b...@tahzoo.com>  |  W:
> *www.tahzoo.com* <http://www.tahzoo.com>
> A:  *Delftechpark 37I , 2628 XJ Delft, Netherlands*
> <https://www.google.com/maps/place/Delftechpark+37,+2628+XJ+Delft,+Netherlands/@51.997531,4.3824845,17z/data=!3m1!4b1!4m5!3m4!1s0x47c5b589ec2c237b:0x22b6e5d15befb3d5!8m2!3d51.997531!4d4.3846732>
>
>
> _______________________________________________
> General mailing list
> General@developer.marklogic.com
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
General@developer.marklogic.com
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to