xsl-list
[Top] [All Lists]

Re: Grouping with keys

2006-02-07 08:12:24
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, what´s 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(_at_)mulberrytech(_dot_)com
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
======================================================================


--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>