Re: [MarkLogic Dev General] Why does fn:replace gives an error when second argument exceeds certain length

2016-10-17 Thread Florent Georges
Hi,

Johan does not seem to have got any answer on this one.  Is it a hard
limit, to be less than 1,500 chars for a regex?  Is this limit going to be
kept in ML9?

Just curious...

Regards,

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


On 22 August 2016 at 13:41, Florent Georges wrote:

> I see...  So I guess the question is not "Why does ML treat the second
> argument as a string or as a regex sometimes?"  The second argument is
> always a string, which must be a valid lexical regular expression.
>
> But would rather be: "Do you confirm ML has a limitation on the length of
> a regex, which appears to be 1463 characters?"
>
> And of course: "Why?"  Good question indeed...
>
> --
> Florent Georges
> http://fgeorges.org/
> http://h2oconsulting.be/
>
>
> On 22 August 2016 at 13:27, Johan de Boer wrote:
>
>> All,
>>
>>
>> I have simplified my example in the XQuery Console to:
>>
>>
>> let $string1 := ""
>> let $string2 := ""
>> let $length-1 := 1463
>> let $length-2 := 1464
>> let $string3 :=
>> fn:string-join
>> (for $a in 1 to $length-1
>>  return 'x')
>> return fn:replace($string1,$string3,$string2)
>>
>> Now using the length of 1463 it works fine. It is seen as a string a that
>> is what I want. But incremented the length by only 1 to 1464 (so replacing
>> $length-1 by $length-2 in the above example) I got the error:
>> XDMP-REGEX: (err:FORX0002) fn:replace("",
>> "...",
>> "") -- Invalid regular expression But I just want that Marklogic
>> also treats the the string of length 1464 as a string and not as regular
>> expression. So the question is:
>>
>> Why does MarkLogic treat a second argument in fn:replace as a string when
>> it has length 1463 (or less) and why does it treat it as a regular
>> expression when it has length 1464 (or more)?
>>
>> It is not about the usefulness of the above example. It is about why the
>> error appears. This example is just a simplifying of a situation which
>> happens in a production environment.
>>
>>
>> Regards,
>>
>>
>> Johan
>>
>> <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*   |  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>
>>
>> --
>> *From:* general-boun...@developer.marklogic.com <
>> general-boun...@developer.marklogic.com> on behalf of Florent Georges <
>> li...@fgeorges.org>
>> *Sent:* Monday, August 22, 2016 1:10:27 PM
>> *To:* MarkLogic Developer Discussion
>> *Subject:* Re: [MarkLogic Dev General] Why does fn:replace gives an
>> error when second argument exceeds certain length
>>
>> 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 "" 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 := ""
>>> let $string2 := ""
>>> let $length-1 := 1463
>>> let $length-2 := 1464
>>> let $piece-of-xml := '>> status="created"/>ABCD
>>> EF GABCD EF
>>> GABCD EF
>>> GHABCD EF
>>> GAbcd
>>> AbcdefghAbcd
>>> AbcdefghABCD EF
>>> GHAbcd
>

Re: [MarkLogic Dev General] Why does fn:replace gives an error when second argument exceeds certain length

2016-08-22 Thread Florent Georges
I see...  So I guess the question is not "Why does ML treat the second
argument as a string or as a regex sometimes?"  The second argument is
always a string, which must be a valid lexical regular expression.

But would rather be: "Do you confirm ML has a limitation on the length of a
regex, which appears to be 1463 characters?"

And of course: "Why?"  Good question indeed...

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


On 22 August 2016 at 13:27, Johan de Boer wrote:

> All,
>
>
> I have simplified my example in the XQuery Console to:
>
>
> let $string1 := ""
> let $string2 := ""
> let $length-1 := 1463
> let $length-2 := 1464
> let $string3 :=
> fn:string-join
> (for $a in 1 to $length-1
>  return 'x')
> return fn:replace($string1,$string3,$string2)
>
> Now using the length of 1463 it works fine. It is seen as a string a that
> is what I want. But incremented the length by only 1 to 1464 (so replacing
> $length-1 by $length-2 in the above example) I got the error:
> XDMP-REGEX: (err:FORX0002) fn:replace("",
> "...",
> "") -- Invalid regular expression But I just want that Marklogic also
> treats the the string of length 1464 as a string and not as regular
> expression. So the question is:
>
> Why does MarkLogic treat a second argument in fn:replace as a string when
> it has length 1463 (or less) and why does it treat it as a regular
> expression when it has length 1464 (or more)?
>
> It is not about the usefulness of the above example. It is about why the
> error appears. This example is just a simplifying of a situation which
> happens in a production environment.
>
>
> Regards,
>
>
> Johan
>
> <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*   |  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>
>
> --------------
> *From:* general-boun...@developer.marklogic.com <
> general-boun...@developer.marklogic.com> on behalf of Florent Georges <
> li...@fgeorges.org>
> *Sent:* Monday, August 22, 2016 1:10:27 PM
> *To:* MarkLogic Developer Discussion
> *Subject:* Re: [MarkLogic Dev General] Why does fn:replace gives an error
> when second argument exceeds certain length
>
> 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 "" 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 := ""
>> let $string2 := ""
>> let $length-1 := 1463
>> let $length-2 := 1464
>> let $piece-of-xml := '> when="2015-09-16" who="999">ABCD EF G> when="2015-09-17" who="999">ABCD EF G> when="2015-09-22" who="99">ABCD EF GH> when="2015-10-09" who="999">ABCD EF G> when="2016-04-01" who="999">Abcd Abcdefgh> when="2016-04-02" who="999">Abcd Abcdefgh> when="2016-04-06" who="99">ABCD EF GH> when="2016-04-09" who="999">Abcd Abcdefgh> when="2016-04-10" who="999">Abcd Abcdefgh> when="2016-04-18" who="999">Abcd Abcdef> when="2016-04-22" who="999">Abcd Abcdefgh> when="2016-04-23" who="99

Re: [MarkLogic Dev General] Why does fn:replace gives an error when second argument exceeds certain length

2016-08-22 Thread Johan de Boer
All,


I have simplified my example in the XQuery Console to:


let $string1 := ""
let $string2 := ""
let $length-1 := 1463
let $length-2 := 1464
let $string3 :=
fn:string-join
(for $a in 1 to $length-1
 return 'x')
return fn:replace($string1,$string3,$string2)

Now using the length of 1463 it works fine. It is seen as a string a that is 
what I want. But incremented the length by only 1 to 1464 (so replacing 
$length-1 by $length-2 in the above example) I got the error:
XDMP-REGEX: (err:FORX0002) fn:replace("", 
"...", "") 
-- Invalid regular expression
But I just want that Marklogic also treats the the string of length 1464 as a 
string and not as regular expression. So the question is:

Why does MarkLogic treat a second argument in fn:replace as a string when it 
has length 1463 (or less) and why does it treat it as a regular expression when 
it has length 1464 (or more)?

It is not about the usefulness of the above example. It is about why the error 
appears. This example is just a simplifying of a situation which happens in a 
production environment.


Regards,


Johan



Johan de Boer
Developer Java / Developer MarkLogic
P: 0031 88 268 2500 | M: 0031 6 444 22 758
E: johan.de.b...@tahzoo.com | W: www.tahzoo.com
A: Delftechpark 37I
, 2628 XJDelft, Netherlands

From: general-boun...@developer.marklogic.com 
 on behalf of Florent Georges 

Sent: Monday, August 22, 2016 1:10:27 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] Why does fn:replace gives an error when 
second argument exceeds certain length

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 "" 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 := ""
let $string2 := ""
let $length-1 := 1463
let $length-2 := 1464
let $piece-of-xml := 'ABCD EF GABCD EF GABCD EF GHABCD EF GAbcd AbcdefghAbcd AbcdefghABCD EF GHAbcd AbcdefghAbcd AbcdefghAbcd AbcdefAbcd AbcdefghAbcd AbcdefghAbcd AbcdefghAbcdef AbcdefghijkAbcdef AbcdefghijkAbcd AbcdefghAbcd AbcdefghAbcdef AbcdefghijkAbcd AbcdefghAbcdef 
Abcdefghijk'
let $test1 := fn:substring($piece-of-xml,1,$length-1)
return fn:replace($string1,$test1,$string2)

This returns the expected value ''.

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("", "...", "") -- 
Invalid regular expression
The value of $test1 at that point is:

ABCD EF GABCD EF GABCD EF GHABCD EF GAbcd AbcdefghAbcd AbcdefghABCD EF GHAbcd AbcdefghAbcd AbcdefghAbcd AbcdefAbcd AbcdefghAbcd AbcdefghAbcd AbcdefghAbcdef AbcdefghijkAbcdef AbcdefghijkAbcd AbcdefghAbcd AbcdefghAbcdef AbcdefghijkAbcd Abcdefghhttp://www.tahzoo.com>
Johan de Boer
Developer Java / Developer MarkLogic

P:  0031 88 268 2500 |  M:  0031 6 
444 22 758

E:  johan.de.b...@tahzoo.com<mailto: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>


[cid:image504001.png@B53C5404.9EAEAF4B]




___
General mailing list
General@developer.marklogic.com<mailto: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


Re: [MarkLogic Dev General] Why does fn:replace gives an error when second argument exceeds certain length

2016-08-22 Thread Florent Georges
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 "" 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 := ""
> let $string2 := ""
> let $length-1 := 1463
> let $length-2 := 1464
> let $piece-of-xml := ' when="2015-09-16" who="999">ABCD EF G when="2015-09-17" who="999">ABCD EF G when="2015-09-22" who="99">ABCD EF GH when="2015-10-09" who="999">ABCD EF G when="2016-04-01" who="999">Abcd Abcdefgh when="2016-04-02" who="999">Abcd Abcdefgh when="2016-04-06" who="99">ABCD EF GH when="2016-04-09" who="999">Abcd Abcdefgh when="2016-04-10" who="999">Abcd Abcdefgh when="2016-04-18" who="999">Abcd Abcdef when="2016-04-22" who="999">Abcd Abcdefgh when="2016-04-23" who="999">Abcd Abcdefgh when="2016-06-26" who="999">Abcd Abcdefgh when="2016-06-27" who="999">Abcdef
> AbcdefghijkAbcdef
> Abcdefghijk who="999">Abcd Abcdefgh who="999">Abcd Abcdefgh who="999">Abcdef Abcdefghijk when="2016-07-03" who="999">Abcd Abcdefgh when="2016-07-03" who="999">Abcdef Abcdefghijk listChange>'
> let $test1 := fn:substring($piece-of-xml,1,$length-1)
> return fn:replace($string1,$test1,$string2)
>
> This returns the expected value ''.
>
> 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("", " when="2015-01-21" status="created"/>...", "") --
> Invalid regular expression The value of $test1 at that point is:
>
>  who="999">ABCD EF G who="999">ABCD EF G who="99">ABCD EF GH who="999">ABCD EF G who="999">Abcd Abcdefgh who="999">Abcd Abcdefgh who="99">ABCD EF GH who="999">Abcd Abcdefgh who="999">Abcd Abcdefgh who="999">Abcd Abcdef who="999">Abcd Abcdefgh who="999">Abcd Abcdefgh who="999">Abcd Abcdefgh who="999">Abcdef Abcdefghijk when="2016-06-28" who="999">Abcdef 
> AbcdefghijkAbcd 
> AbcdefghAbcd 
> AbcdefghAbcdef 
> AbcdefghijkAbcd 
> Abcdefghhttp://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*   |  W:
> *www.tahzoo.com* 
> A:  *Delftechpark 37I , 2628 XJ Delft, Netherlands*
> 
>
>
> ___
> 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


Re: [MarkLogic Dev General] Why does fn:replace gives an error when second argument exceeds certain length

2016-08-22 Thread DK Singh
Hi John,
You are giving the wrong parameters in the second argument of fn: replace ,
replace work on patterns or the and you are passing second argument as
string,
So I think for the second argument in fn: replace you will have to provide
regex

On Aug 22, 2016 3:34 PM, "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 := ""
let $string2 := ""
let $length-1 := 1463
let $length-2 := 1464
let $piece-of-xml := 'ABCD EF GABCD EF GABCD EF GHABCD EF GAbcd AbcdefghAbcd AbcdefghABCD EF GHAbcd AbcdefghAbcd AbcdefghAbcd AbcdefAbcd AbcdefghAbcd AbcdefghAbcd AbcdefghAbcdef
AbcdefghijkAbcdef
AbcdefghijkAbcd AbcdefghAbcd AbcdefghAbcdef AbcdefghijkAbcd AbcdefghAbcdef Abcdefghijk'
let $test1 := fn:substring($piece-of-xml,1,$length-1)
return fn:replace($string1,$test1,$string2)

This returns the expected value ''.

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("", "...", "") --
Invalid regular expression The value of $test1 at that point is:

ABCD EF GABCD EF GABCD EF GHABCD EF GAbcd AbcdefghAbcd
AbcdefghABCD EF GHAbcd AbcdefghAbcd
AbcdefghAbcd AbcdefAbcd
AbcdefghAbcd AbcdefghAbcd
AbcdefghAbcdef AbcdefghijkAbcdef
AbcdefghijkAbcd AbcdefghAbcd
AbcdefghAbcdef AbcdefghijkAbcd
Abcdefghhttp://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*   |  W:
*www.tahzoo.com* 
A:  *Delftechpark 37I , 2628 XJ Delft, Netherlands*



___
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