[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

Re: [xsl] Help parsing a node

Subject: Re: [xsl] Help parsing a node
From: Michael Kay <mike@xxxxxxxxxxxx>
Date: Thu, 26 Apr 2012 18:18:40 +0100

On 26/04/2012 16:51, Michele R Combs wrote:
Hi all --

Can someone translate this into plain English for me?

<xsl:variable name="uniqueTypes" select="ead/archdesc/dsc/descendant::*/container[not(@type=following::*/container/@type)]/@type" />
Roughly, it selects all the @type attributes provided there is no @type attribute later in the document with the same value.

And it does this very inefficiently (n*2 performance where n is the document size) - it can be done much more efficiently using keys.

It also doesn't do quite what I said. Assuming it's used with "/" as the context item, It's actually looking for all @type attributes whose path is /ead/archdesc/dsc//container, provided they aren't the same as a following @type attribute whose path is //container. If there are @type attributes that match the first path and not the second, that could lead to some strange effects.

It could even select duplicates. If there happens to be a structure like this:

<container type="x">
<container type="x"/>

then both type attributes will be selected, because the second is not "following" the first.

Michael Kay

What exactly will this select? And (since it starts with the root node) will it select the exact same thing no matter where it's used?

I thought I knew but it isn't behaving at all the way I expected.

Thanks --

Michele Combs
Lead Archivist
Special Collections Research Center
Syracuse University

Current Thread