0

I am trying to use the dynamic Xquery and forming the path using the external variable.
My query is:

xquery version "1.0-ml";
declare variable $idValue as xs:string external;
declare variable $element as xs:string external;
for $sectiondiv in doc()//$element 
return $sectiondiv; 

Here I want to send the $element query from java and execute the query. Element is string path of xml element.

sample xml

<rationales id="RATIONALE">
    <rationalesbody>
        <rationale>
            <title>Rationales</title>
            <sectiondiv id="RAT_1" population="pediatric">
                <p>THis is sample SectionDiv content </p>
            </sectiondiv>
        </rationale>         
    </rationalesbody>
</rationales>       

So the element value I sending is /rationales /rationalesbody/rationale idValue = RAT_1

It should return me sectiondiv and it's childs.

1 Answers1

0

I was looking for the same thing and found this:

$doc//*[name() eq $element]
Ebrahim Poursadeqi
  • 1,776
  • 2
  • 17
  • 27