Subject: Re: [xsl] Pattern Matching in XSl - find groups defined in one Xml in another Xml. From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 23 Aug 2012 12:56:23 -0400 |
So it seems that the use of the key statement and function gives functionality the same as can be got by using a predicate in a certain way. It is presumably advised in some cases as an opportunity for the processor to optimize the search. In my case the data is probably not large enough for this optimization to make much difference to the processing time.
<xsl:apply-templates select="key('p-by-id','p2')"/>
applies a template to the p2 'p' element,
So the same as<xsl:apply-templates select="p[ @id = 'p2' ]"/>
<xsl:apply-templates select="key('p-by-id','np1')"/>
applies a template to the np1 'p' element.
So the same as<xsl:apply-templates select="p[ @id = 'np1' ]"/>
key('element-by-id',@rid)
retrieves nodes using the 'element-by-id' key by the value of the @rid attribute of the context node.
something like "element[ @id = ./@rid ]" (assuming<xsl:key name="element-by-id" match="element" use="@id"/> and that "element" is not a reserved word. )
It does sound like keys implicitly work using "=", though. So there's no key based equivalent to "element[ @id> ./@rid ]" ?
<xsl:key name="greater-element" match="*" use="(min(//@id/xs:integer(.)) to max(//@id/xs:integer(.))) [. lt xs:integer(current()/@id)]"/>
Having said all that, as you say, my requirement for RE matching does seem to rule out use of keys.
I was going to ask (for academic interest really) what would happen if a key had duplicate matches ? (error at indexing time ? return all the matching elements ? return the first ?) You do say:* Keys can (and frequently do) retrieve more than one node at a time;So I presume a sequence of all the matches would be returned in that case. Likewise if the requested key was a sequence a sequence would be returned assuming all distinct keys produced a separate match.
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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
RE: [xsl] Pattern Matching in XSl -, Kerry, Richard | Thread | RE: [xsl] Pattern Matching in XSl -, G. Ken Holman |
RE: [xsl] Pattern Matching in XSl -, G. Ken Holman | Date | [xsl] [ANN] XML Amsterdam 2012 regi, XML Amsterdam |
Month |