Your First XQueries

Try a few simple examples to get acquainted with XQuery. Start Stylus Studio, and open a new XQuery document ( File > New > XQuery File). Save the file now (if you do not, Stylus Studio will prompt you to save it when you preview your first XQuery).

Type the following in the XQuery Editor:


              "Hello, world!"
               

            

Now, click the Preview Result button ( ), and Stylus Studio displays the result of this XQuery in the Preview window:

"Hello, world!"
               

            

Enter a simple equation ( 2+2) and click the Preview Result button ( ). Predictably, the result is:

4
               

            

Finally, try the XQuery function current-time() and click the Preview Result button ( ):

11:27:38Z
               

            

Your results, will vary based on several conditions. For example, the XQuery processor you use to execute the XQuery will affect the precision of the time value (fractions of seconds), and the time zone (here, shown as Z) is determined by how your system is configured.

None of these is a very useful query on its own, but within a query language you need to be able to perform little calculations and XQuery has this covered. Further, XQuery is designed so that expressions can be fully nested - that is, any expression can be used within any other expression, provided that it delivers a value of the right type - and this means that expressions that are primarily intended for selecting data within a where clause can also be used as free-standing queries in their own right.

ETL - Extract, Transform, Load

Designing Extract, Load and Tranform (ETL) applications including ETL data warehousing, etl design and etl programming is easy with Stylus Studio's XML and ETL Tools. Start ETL Programming today.

XMLSCHEMA-DEV Blog

XML Schema-DEV is an active community for XML Schema-releated development - join the discussion on XML Schema standards, tools, implementations and more. Bookmark this RSS or ATOM feed today!

DTD vs. Schema

Stylus Studio provides tools for working with both W3C XML Schema and DTD's - this tutorial explains what the differences are between the two, providing a technical comparison of DTD vs Schema.

XML-DEV Discussion Forum

XML-DEV is a leading technical forum for XML discussion and a valuable free XML learning resource. Subscribe to the XML-DEV email discussion forum today to help further your XML education.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member