Re: Selecting multi-existant elements only once
For *every* node on *every* level (independent of some processor specific optimizations) the conditions will be evaluated. This means every node will be tested for:
- name is profession
- parent is departement
- the string value of a node desc is compared to again *every* preceding node on *every* level with name desc
If you change it only a bit, the code will at least in larger lists much faster:
<xsl:for-each select="/departement/profession[not(desc = preceding-sibling::profession/desc)]">
The removing of the '//' reduces the <profession> elements exactly to only the elements on the second "level" (there is no "level" in XML, but I think you know what I mean: only one ancestor element). And the using of preceding-sibling axis reduces the necessary tests in the predicate more or less enormously, because you can tell the processor exactly where to find the desc elements and again it must not search them on every "level".
At the end the key solution:
<xsl:key name="professions" match="profession" use="desc"/>
<xsl:for-each select="/department/profession[generate-id() = generate-id(key('professions', desc))]">
I wrote:Hi all,
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
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