Grouping

If you are used to SQL, then you might have been wondering what the equivalent to its DISTINCT and GROUP BY keywords is in XQuery FLOWR expressions. Well, SQL does not have one.

You can, however, get a fair amount of mileage from the distinct-values() function. Here is a query that groups videos according to who directed them:


              <movies>
               

                 {for $d in distinct-values(//director) return
               

                    <director name="{$d}">
               

                    { for $v in //video[director = $d] return
               

                       <title>{$v/title}</title>
               

                    }
               

                    </director>
               

                 }
               

              </movies>
               

            

This is not an ideal solution: apart from anything else, it depends heavily on the ability of the query processor to optimize the two nested loops to give good performance. But for the time being, this is all there is. This is an area where vendors are very likely to offer extensions to the language as defined by W3C.

Grouping was a notoriously weak point of XSLT 1.0, and the problem has been addressed with considerable success in the 2.0 version of the language. XQuery will likely follow suit.

DataDirect XML Converters

DataDirect XML Converters are high-performance Java components which provide bi-directional, programmatic access to virtually any data source as XML.

XML Schema Validator, DTD Validator

Stylus Studio lets you validate XML documents using integrated XML Schema or DTD validators. Use the Stylus Studio built-in validator, or any number of supported XML parsers and XML validators like MSXML SAX and DOM, Xerces, .NET, and more!

XML Schema Mapping

Stylus Studio includes a visual XML Schema-to-XML Schema mapping tool that allows you to easily implement sophisticated XML data mappings involving multiple data sources and customized data processing using either XSLT or XQuery code.

Web Service Data-to-XML Mapper

Stylus Studio provides a powerful standards-based solution for accessing and transforming live Web service XML data. Intuitive tools like the Web Service Call Composer and UDDI Browser make developing Web service applications a snap.

Stylus Most Wanted

 
Free Stylus Studio XML Training:
W3C Member