devxlogo

Using the &lt< and &gt> XQuery Operators

When you want to determine the order of articles into an sequence returned by an XQuery query, you can use the << and >> operators:

    - X << Y: is true if X is before Y;    - X >> Y: is true if Y is before X;

For example, suppose you have the following sequence of strings:

Shark, Daisy, Hunter, Lego, Helly

Use this query:

let $xml:=doc(?file:///C://Data_Local//xml//AirWings.xml?)for $a in $xml/company/aircrafts  for $b in  $xml/company/aircrafts   return(if($a/type<<$b/type) then concat($a/type/@M,"--]",$b/type/@M) 	else concat($a/type/@M,"[--",$b/type/@M)   )

The query returns:

Shark[--Shark, Shark--]Daisy, Shark--]Hunter, Shark--]Lego,Shark--]Helly, Daisy[--Shark, Daisy[--Daisy, Daisy--]Hunter,Daisy--]Lego, Daisy--]Helly, Hunter[--Shark, Hunter[--Daisy,Hunter[--Hunter, Hunter--]Lego, Hunter--]Helly, Lego[--Shark,Lego[--Daisy, Lego[--Hunter, Lego[--Lego, Lego--]Helly ,Helly[--Shark, Helly[--Daisy, Helly[--Hunter, Helly[--Lego,Helly[--Helly

Charlie has over a decade of experience in website administration and technology management. As the site admin, he oversees all technical aspects of running a high-traffic online platform, ensuring optimal performance, security, and user experience.

See also  Five Early Architecture Decisions That Quietly Get Expensive

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.