Accessing XML Documents with XQuery

Though XQuery is capable of handling mundane tasks like those described in the previous section, it is designed to access XML data. Right now, we will look at some simple queries that require an XML document as their input. For this purpose, we will use videos.xml, which is installed with Stylus Studio in the \examples\VideoCenter directory. You can also find a copy of this XML document on the Stylus Studio Web site.

XQuery allows you to access the file directly from either of these locations, using a suitable URL as an argument for its doc() function. If you wanted to retrieve and display the entire file from your Stylus Studio installation directory, your doc() might look like this:

doc('file:///c:/Program%20Files/Stylus%20Studio%202008%20XML%20Professiona
l %20Suite/examples/VideoCenter/videos.xml') 

To fetch this document from the Stylus Studio Web site, you would need a doc() like this:

doc('http://www.stylusstudio.com/examples/videos.xml')  

(The latter doc() function will work only if you are online; and if you are behind a corporate firewall you might have to modify your Java configuration to make it work.)

Handling URLs

URLs like those used in the previous example can be a bit unwieldy, but there are some shortcuts you can use.

The videos.xml Document

The videos.xml document contains a number of sections: video_template, actors, and videos. You might want to open this document in the XML Editor to get acquainted with it if you are not already familiar with it.

XML Helps Uncork Innovative Winery Web Sites

Learn how Freerun Technologies, Inc., a leading Internet services provider used Stylus Studio and XML technologies to develop a framework for Web-based eCommerce applications for the wine industry, reducing development cycles.

Translating XML documents to X12

In-place, via XSLT and via XQuery are all mechanisms supported for converting XML to X12

Export HTML to XML

Export HTML to XML with the click of a button - simplify migration of legacy HTML code to industry standard XML technologies with Stylus Studio.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member