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

Re: Grouping with keys

Subject: Re: Grouping with keys
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Tue, 07 Feb 2006 10:12:24 -0500
Re:  Grouping with keys
Dear Silvia,

At 08:11 AM 2/7/2006, you wrote:
Hi prakash,

thanks for helping, this is a good idea, but in my "big" xslt, i have a
construction, where i need a solution with a key.

have you/someone an idea, what4s wrong in my key version?
>
> <xsl:key name="heading" match="wordDorcument/body/sect/p"
> use="generate-id((preceding-sibling::p[pPr/pStyle/@val='Heading1'" />
> <xsl:key name="prog" match="pPr/pStyle/@val='Programlisting'"
> use="generate-id((preceding-sibling::p[pPr/pStyle/@val='Programlisting'"
> />

Without parsing out your XPath, two things come to mind:


* The XPath on the @use attribute isn't
syntactically correct, which one can see readily
due to the lack of closing brackets or
parentheses. This should give you an error.
* You'll probably also want to find the *first*
or immediately preceding p sibling with the selection criterion, as in

generate-id(preceding-sibling::p[pPr/pStyle/@val='Heading1'][1])

-- which you'll need since otherwise you'll get
the generated id of the first such p on the axis
in document order, which isn't what you want for this grouping idiom.

But it may be worth trying Prakash's solution if
it's simpler (hence easier to construct, code and
maintain). People often assume they have to
optimize for performance before they actually do.

I recently saw a fabulous old advertisement for a
machine tooling manufacturer: "If you know you
need new tools and you haven't yet acquired them,
you're already paying for them". This applies to
programming too. But the converse is also true:
if you don't know you need new tools but have
already acquired them, you may be paying extra.

Cheers,
Wendell



======================================================================
Wendell Piez                            mailto:wapiez@xxxxxxxxxxxxxxxx
Mulberry Technologies, Inc.                http://www.mulberrytech.com
17 West Jefferson Street                    Direct Phone: 301/315-9635
Suite 207                                          Phone: 301/315-9631
Rockville, MD  20850                                 Fax: 301/315-8285
----------------------------------------------------------------------
  Mulberry Technologies: A Consultancy Specializing in SGML and XML
======================================================================

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.