Example of Calling the document() Function

Suppose you have the following XML document:

<?xml version="1.0" encoding="UTF-8"?> 
               
<books> 
               

              
<bookstore>bookstore1:bookstore1.xml</bookstore> 
                   
<bookstore>bookstore2:bookstore2.xml</bookstore> 
                   
<bookstore>bookstore3:bookstore3.xml</bookstore>
                   

                
</books>

The following query returns the bookstore elements:

/books/bookstore
               

            

Now suppose you pass this query to the document() function as follows:

document(/books/bookstore)
               

            

This query returns the root nodes of bookstore1.xml, bookstore2.xml, and bookstore3.xml.

 
Free Stylus Studio XML Training: