|
[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message] return only latest version of an itemG. Ken Holman gkholman at CraneSoftwrights.comThu May 14 15:23:24 PDT 2009
At 2009-05-14 14:18 -0400, A. Steven Anderson wrote: >I've got a pretty complex xquery that returns only the latest >version of all items in a collection, but I know there has got to be >a more efficient way to do it. >... >What would be the most efficient way to do this? By which criteria are you trying to measure efficiency? Below is an example using max() I hope this helps. . . . . . . . . Ken t:\ftemp>type steven.xml <items> <item> <id>1</id> <name>item # 1</name> <version>1</version> </item> <item> <id>1</id> <name>item # 1</name> <version>2</version> </item> <item> <id>1</id> <name>item # 1</name> <version>3</version> </item> <item> <id>2</id> <name>item # 2</name> <version>1</version> </item> <item> <id>2</id> <name>item # 2</name> <version>2</version> </item> <item> <id>3</id> <name>item # 3</name> <version>1</version> </item> </items> t:\ftemp>type steven.xq /items/item[version=max(/items/item/version)] t:\ftemp>xquery steven.xml steven.xq con <?xml version="1.0" encoding="UTF-8"?> <item> <id>1</id> <name>item # 1</name> <version>3</version> </item> t:\ftemp> -- XQuery/XSLT/XSL-FO hands-on training - Los Angeles, USA 2009-06-08 Crane Softwrights Ltd. http://www.CraneSoftwrights.com/q/ Training tools: Comprehensive interactive XSLT/XPath 1.0/2.0 video Video lesson: http://www.youtube.com/watch?v=PrNjJCh7Ppg&fmt=18 Video overview: http://www.youtube.com/watch?v=VTiodiij6gE&fmt=18 G. Ken Holman mailto:http://x-query.com/mailman/listinfo/talk Male Cancer Awareness Nov'07 http://www.CraneSoftwrights.com/q/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|






