[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Techniques for Sorting and Reducing Maps in XSLT

Subject: Re: Techniques for Sorting and Reducing Maps in XSLT 3/XPath 3?
From: "Liam R. E. Quin liam@xxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 6 Jul 2018 16:28:15 -0000
Re:  Techniques for Sorting and Reducing Maps in XSLT
On Thu, 2018-07-05 at 20:51 +0000, Eliot Kimber ekimber@xxxxxxxxxxxx
wrote:
> [...]

> maps seem like an obvious way to do this:
> 
> 1. Use Saxon's collection() function with the metadata=yes option to
> get a set of maps, one for each file, that includes the full path to
> the file (this avoids loading a bunch of files I don't actually want
> and gives me maps as a starting point).
> 
> 2. Using these maps, add the version, locale, and 3rd-level directory
> name as separate entries in each map, creating a more complete set of
> "descriptor" maps that make it easy to access to relevant fields I
> care about.
> 
> 3. Create a new map where the keys are 3rd directory name ("course
> ID") and the values are the descriptor maps a given course id/locale
> pair with the highest version.
> 
> My question: How best to implement step 3?

If you keep the values as tree nodes, you shuld be able to use base-
uri() and/or document-uri() to get at the filename.

On your xsl:iterate question, i'd generally try for-each and/or for-
each-group before xsl:iterate. The reason is largely that i think it
encourage thinking in terms of a functional mapping rather than an
imperative loop, and that can help clarity of thought.

> What is the better way to do this kind of "find the map entries that
> meet a specific requirement relative to other members of the map"
> processing?

Well, this sounds like an XQuery question of course, where you want to
process a tuple stream with a where clause. But in XSLT it also sounds
like a sort of Visitor pattern where you'd pass in an isWanted function
to a recursive tree walk; the tree walk would know about your map
structure enough to visit every node you cared about, and would use
isWanted() to return only the appropriate nodes. (there are some
performance optimizations you can do with this architecture too of
course, e.g. letting isWanted also say, "all done, stop looking now")

Don't know if this helps. 

Liam

-- 
Liam Quin,  http://www.fromoldbooks.org/

Available for XML/Document/Information Architecture/
XSLT/XQuery/Web/Text Processing work and consulting.

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.