[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] Re: XPath shorthand
On Tue, Aug 21, 2012 at 8:28 PM, Andrew Welch <andrew.j.welch@xxxxxxxxx> wrote: >>>>> In the end I went with >>>>> >>>>> <xsl:key name="desired_fields" >>>>> match="m__id[1]|m__name[1]|m__path[1]|m__enabled[1]" >>>>> use="local-name()"/> >>>>> >>>>> and >>>>> >>>>> following-sibling::*[key('desired_fields',local-name())] >>> >>> Why do that? >>> >> >> Because then all my end-user has to do if he wants to change the >> fields being retrieved is add (or subtract) the relevant element name >> from the match pattern. > > ..in which case: > > <xsl:variable name="names" select="('m__id', 'm__name', > 'm__path'....)" as="xs:string+"/> > > with > > following-sibling::*[local-name() = $names] > Yes I didn't think of this but there are two things. This won't work in a template match on XSLT 1.0 and it is hiding multiple comparisons under the innocent looking equality general comparison which may bite on large volumes. Unfortunately I don't have the volume of data to benchmark the keys solution vs the variable solution. I presume your preference for variables is based on better performances (at least until volumes start to get large).
|
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
|