You can't use variables as steps in XPath as a way to select a node.

If you do this:

let $data :=
<data>
  <r>
    <abc function="w:remove-spaces" module="/datafab/process.xqy"/>
   <cdb function="w:spaces" module="/datafab/process1.xqy"/>
  </r>
</data>

let $step := "abc"

return $data/r/$step

Then the result will just be the string "abc".

If you want to dynamically select the node "abc" you'd have to do something 
like:


let $data :=
<data>
  <r>
    <abc function="w:remove-spaces" module="/datafab/process.xqy"/>
   <cdb function="w:spaces" module="/datafab/process1.xqy"/>
  </r>
</data>

let $step := "abc"

return $data/r/*[local-name(.) = $step]

which returns 
<abc function="w:remove-spaces" module="/datafab/process.xqy"/>


From: [email protected]
To: [email protected]
Date: Wed, 27 Oct 2010 15:17:33 +0530
Subject: [MarkLogic Dev General] xpath
















Hi,

 

The following query gives the empty string instead of
<abc> element . Also, I need to use $rule.

 

xquery version "1.0-ml";

import module namespace constant = "http://www.lexisnexis.com/constants";

    at "/datafab/constants.xqy";

let  $rule := (“abc”,”cdb”)

return

$constant:CONFIG/data/r/$rule/@function

 

The xml used is :

<data>

  <r>

    <abc function="w:remove-spaces"
module="/datafab/process.xqy"/>

   <cdb function="w: spaces"
module="/datafab/process1.xqy"/>

 

  </r>

</data>

 

Let me know, if I am missing anything.

 

Thanks,

Pragya







**************** CAUTION - Disclaimer *****************
This e-mail contains PRIVILEGED AND CONFIDENTIAL INFORMATION intended solely 
for the use of the addressee(s). If you are not the intended recipient, please 
notify the sender by e-mail and delete the original message. Further, you are 
not 
to copy, disclose, or distribute this e-mail or its contents to any other 
person and 
any such actions are unlawful. This e-mail may contain viruses. Infosys has 
taken 
every reasonable precaution to minimize this risk, but is not liable for any 
damage 
you may sustain as a result of any virus in this e-mail. You should carry out 
your 
own virus checks before opening the e-mail or attachment. Infosys reserves the 
right to monitor and review the content of all messages sent to or from this 
e-mail 
address. Messages sent to or from this e-mail address may be stored on the 
Infosys e-mail system.
***INFOSYS******** End of Disclaimer ********INFOSYS***

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

Reply via email to