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

RE: efficiency with id()

Subject: RE: efficiency with id()
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Thu, 3 Jul 2003 12:13:05 +0100
gap c1003
The answer to performance questions is always to measure it and see. You
won't necessarily get the same results from two different processors.

I would expect id() and key() to give similar performance, but if the
attribute is an ID then there's no point also defining it as a key, that
would just give you two indexes; a processor won't normally build an
index for a key unless you actually use it, but this may or may not be
true for IDs.

If your task is to load the document from disk and extract a single
element, then an index isn't going to help you much because the cost of
building it outweighs the benefit it gives you. You might as well use a
straight predicate, such as //p[@id='xyz'].

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> James Cummings
> Sent: 03 July 2003 10:41
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  efficiency with id()
> 
> 
>  Ok, let's say you have a file of:
> -----
>  <?xml version="1.0"?>
>  <foo>
>  <bar>
>  <blort>
>  <p id="c1001"><body wit="A B C">This is a
>               <app><rdg wit="A B">test</rdg><rdg 
> wit="C">really big test</rdg></app>
>               but only a test!</body></p>
>  <p id="c1002"><body wit="A B C">This is a
>               <app><rdg wit="A B">test</rdg><rdg 
> wit="C">really big test</rdg></app>
>               but only a test!</body></p>
>  <p id="c1003"><body wit="A B C">This is a
>               <app><rdg wit="A B">test</rdg><rdg 
> wit="C">really big <add> place="supra">test</add></rdg></app>
>               but only a test!</body></p>
>  ...
>  <p id="c9205"><body wit="A B C">This is a
>               <app><rdg wit="A B">test</rdg><rdg 
> wit="C">really <gap/>test</rdg></app>
>               but only a test!</body></p>
>  </blort>
>  </bar>
>  </foo>
> -----
> 
> What is the most efficient/quickest way of grabing a copy-of 
> a particular <p> (and
> children) by its @id?
> 
> 
> Is it best to do something like:
> -----
> <xsl:template match="/">
>   <xsl:copy-of select="id($id)"/>
> </xsl:template
> 
> <!-- and another empty template matching anything you don't 
> want to display -->
> -----
> 
> or is there a quicker way? Is key() quicker?  The @id is in 
> reality declared as type ID, so seems reasonable to use that. 
>  (This is for a quite large (well 2.5meg), file, which 
> admittedly would probably be better just burst out into 
> seperate files for each <p> element in this example.)  Any 
> suggestions appreciated.
> 
> -James
> 
> ---
> Dr James Cummings, James.Cummings@xxxxxxxxx, 
> http://www.uea.ac.uk/~q503 Cursus Project, > School of Music, 
> University of East Anglia, Norwich, Norfolk, NR4 7TJ, UK  
> Tel:(01603)593-595
> 
> 
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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.