Hi,

I tried using the same xdmp:value($exp) without quotes but gives an error:

<error-info>
    <code>500</code>
    <error-type>server</error-type>
    <message>Internal Server Error | err:XPST0003 - Unexpected token</message>
    <description>XDMP-UNEXPECTED: (err:XPST0003) Unexpected token syntax error, 
unexpected $end in  at line number 1</description>
</error-info>

Thanks
Pragya

________________________________________
From: [email protected] 
<[email protected]> on behalf of Florent Georges 
<[email protected]>
Sent: Tuesday, June 16, 2015 3:02 PM
To: MarkLogic Developer Discussion
Subject: Re: [MarkLogic Dev General] xdmp:value query

   Hi,

  I haven't looked in detail (especially whether it is a good idea in
this case to use dynamic evaluation of XQuery, or if you should rather
use something else), but it looks like you want to evaluate the
expression, not resolve a variable name.

  Evaluating the string literal "$exp" gives you the value of the
variable.  Evaluating $exp, means evaluating the value of the variable
as an expression (the value of the variable is a string, "0000049*3").
So just use xdmp:value($exp), with no quote characters.

  Regards,

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


On 16 June 2015 at 11:24, Kapoor, Pragya wrote:
> Hi,
>
>
> I am running the below query :
>
>
> declare namespace MET100 = 'MET100' ;
>
>
> let $output :=
> <user><userId>test1</userId><sessionId>54C76A855C23EF8AC5AFBC59C8D4C40A</sessionId>
>
> <outputs>
>
> <output><columnAlias>CollectionNo</columnAlias>
>
> <functions type="decimal">CollectionNo*3</functions></output>
>
> </outputs></user>
>
>
> let $functions := fn:data($output//functions)
>
> let $docId := '/docs/BONY_0000049_ISDA-CSA-GB95_6749.xml'
>
> let $type := ($output//functions/@type)
>
> let $doc := fn:doc($docId)
>
> let $alias := ($output//columnAlias/text())
>
> let $ns := "MET100"
>
> let $elem := "CollectionNo"
>
> let $element := fn:concat($ns,":",$elem)
>
> let $result :=($doc//*[name() = $element])/text()
>
> let $result :=
>
> if($type eq 'string') then
>
> xdmp:value(xdmp:quote(fn:replace($functions,$alias,fn:concat("'",$result,"'"))))
>
> else
>
>   let $exp := (fn:replace($functions,$alias,$result[1]))
>
>   return xdmp:value("$exp")
>
> return  $result
>
>
> actual output is : 0000049*3
>
> Expected Output is : 147
>
>
> But Since I am using  let $exp := (fn:replace($functions,$alias,$result[1]))
> which returns a string expression, which is causing problem.
>
>
> How can I solve this ?
>
>
> Thanks
>
> Pragya
>
> "This e-mail and any attachments transmitted with it are for the sole use of
> the intended recipient(s) and may contain confidential , proprietary or
> privileged information. If you are not the intended recipient, please
> contact the sender by reply e-mail and destroy all copies of the original
> message. Any unauthorized review, use, disclosure, dissemination,
> forwarding, printing or copying of this e-mail or any action taken in
> reliance on this e-mail is strictly prohibited and may be unlawful."
>
> _______________________________________________
> General mailing list
> [email protected]
> Manage your subscription at:
> http://developer.marklogic.com/mailman/listinfo/general
>
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general
"This e-mail and any attachments transmitted with it are for the sole use of 
the intended recipient(s) and may contain confidential , proprietary or 
privileged information. If you are not the intended recipient, please contact 
the sender by reply e-mail and destroy all copies of the original message. Any 
unauthorized review, use, disclosure, dissemination, forwarding, printing or 
copying of this e-mail or any action taken in reliance on this e-mail is 
strictly prohibited and may be unlawful."
_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to