The Query Input View

A node can be dragged and dropped in the editor area for quickly inserting doc() or other XQuery expressions.

 

Figure 4.96. XQuery input view

XQuery input view

For example for the following XML documents

<movies>
    <movie id="1">
        <title>The Green Mile</title>
        <year>1999</year>
    </movie>
    <movie id="2">
         <title>Taxi Driver</title>
         <year>1976</year>
    </movie>
</movies>
                    

and

<reviews>
 <review id="100" movie-id="1">
   <rating>5</rating>
   <comment>It is made after a great Stephen King book.</comment>
   <author>Paul</author>
 </review>
 <review id="101" movie-id="1">
   <rating>3</rating>
   <comment>Tom Hanks does a really nice acting.</comment>
   <author>Beatrice</author>
 </review>
 <review id="104" movie-id="2">
    <rating>4</rating>
    <comment>Robert De Niro is my favorite actor.</comment>
    <author>Maria</author>
 </review>    
</reviews>
                    

and the following XQuery

let $review := doc("reviews.xml")
for $movie in doc("movies.xml")/movies/movie
    let $movie-id := $movie/@id
return
<movie id="{$movie/@id}">
    {$movie/title}
    {$movie/year}
        <maxRating>
        {
        
        }
        </maxRating>
</movie>
                    

if you drag the rating element and drop between the braces a popup menu will be displayed.

 

Figure 4.97. XQuery Input drag and drop popup menu

XQuery Input drag and drop popup menu

Select for example FLWOR rating and the result document will be:

 

Figure 4.98. XQuery Input drag and drop result

XQuery Input drag and drop result