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

Re: How to design XPath queries and XSLT code that can

Subject: Re: How to design XPath queries and XSLT code that can be readily repurposed?
From: "Graydon graydon@xxxxxxxxx" <xsl-list-service@xxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 2 Aug 2019 18:32:09 -0000
Re:  How to design XPath queries and XSLT code that can
On Fri, Aug 02, 2019 at 06:08:00PM -0000, Costello, Roger L.
costello@xxxxxxxxx scripsit: [snip]
> The complete XSLT program is shown below. I also show the code to
> implement the second task (display, for each route, the gas stations
> at rest stops); notice that the code is essentially a complete rewrite
> of the first task. How can I design the XPath queries and XSLT code so
> that I don't have to do a complete rewrite every time there is a
> requirement change?

Generally, structure around documents and structure around data are
different patterns.  You seem to be doing document structure patterns
when what you've got is data.

Firstly, what you've shown of this looks much more like an XQuery job
("what's in there?") than an XSLT job ("I need to rearrange this").

Secondly, you've got a bunch of keyed data, but the keys repeat because
you've structured it by rows. If you group it into maps, so there's a
single instance of the key and some node structure with the associated
values (all the rest stops on I-84 in the routes2stops map under the
I-84 key, etc.) you can presumably do that grouping once on import.

One you have that, new requirements may add a map grouping but shouldn't
change the existing ones.  What you're doing is feeding keys into maps
and getting back all the associated values; you might then cascade those
returned key values through other maps.  Because maps are a label and
some arbitrary node, some forethought will often allow you to have the
map return the desired output structure.

Thirdly and most meta-y, the procedural approach should be suspect in
XSLT.  Lots of xsl:for-each can be a hint that the requirements didn't
get fully translated into trees-and-functions.

-- Graydon

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.