Yeah, I did a little more testing and was able to get this to work:

let $xml :=
    <docs>
        <doc><test xmlns="some-schema"></test></doc>
        <doc><test xmlns="some-schema"></test></doc>
        <doc><test xmlns="some-schema"></test></doc>
    </docs>
return
    for $x in $xml//doc
    let $try := try { validate strict { $x/node() } } catch ( $e ) { $e }
    return if ( fn:name( $try ) = "error:error" ) then "bad" else "good"

So it doesn't appear to be the validate statement itself. The weird thing is 
that if I take it out of the FLWOR expression, it works fine. I think it may 
have to do with the kind of node I'm sending to the validate expression, but 
I've tried every combination I know and none of them have worked.

SS

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Mary Holstege
Sent: Wednesday, August 11, 2010 2:35 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Using a validate statement inside a FLWOR 
expression

On Wed, 11 Aug 2010 12:57:36 -0700, Stewart Shelline  
<[email protected]> wrote:

> Should I be able to do the following?
>
> for $doc in doc()//some-root-element
> let $try := try { validate strict { $doc } } catch ( $e ) { $e }
> return $try
>
> The offending line is the second one, and I suspect it is the validate  
> statement. But the error message is:
>
> XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error,  
> unexpected ElementContentChars_
>
> Not sure how to read it, but it behaves as if a validate statement is  
> not allowed in a FLWOR expression.
>

That should be perfectly OK.  It looks like some kind of lexer bug.
FWIW your query works OK for me in the latest release.

//Mary

_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general


 NOTICE: This email message is for the sole use of the intended recipient(s) 
and may contain confidential and privileged information. Any unauthorized 
review, use, disclosure or distribution is prohibited. If you are not the 
intended recipient, please contact the sender by reply email and destroy all 
copies of the original message.


_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to