Edit online

The structure of the source documents of an edited XQuery is displayed in a tree form in a view called the XQuery Input view. If the view is not displayed, it can be opened by selecting it from the Window > Show View menu. The tree nodes represent the elements of the documents.

You can use the XQuery Input view to drag and drop a node into the editing area to quickly insert XQuery expressions.

Figure 1. XQuery Input View


For the following XML documents:
                    <movie id="1">
                    <title>The Green Mile</title>
                    <movie id="2">
                    <title>Taxi Driver</title>
                    <review id="100" movie-id="1">
                    <comment>It is made after a great Stephen King book.
                    <review id="101" movie-id="1">
                    <comment>Tom Hanks does a really nice acting.</comment>
                    <review id="104" movie-id="2">
                    <comment>Robert De Niro is my favorite actor.</comment>
and the following XQuery:
                    let $review := doc("reviews.xml")
                    for $movie in doc("movies.xml")/movies/movie
                    let $movie-id := $movie/@id
                    <movie id="{$movie/@id}">

If you drag the review element and drop it between the braces, the following pop-up menu is displayed:

Select FLWOR review, the resulting document will look like this: