Re: [xsl] Help parsing a node

Subject: Re: [xsl] Help parsing a node
From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx>
Date: Thu, 26 Apr 2012 15:39:07 -0400

Martin wrote "xsl:key", but for whatever reason his fingers seem to have typed "xsl:name". Try what he meant to say and it should work.

If you aren't familiar with keys and how powerful and useful they are, now is a good moment to learn. One of their several uses is in getting around scaling problems when grouping (or doing any handling of unique values) in XSLT 1.0.

Also ... your diagnosis is not *quite* correct yet:

<xsl:variable name="uniqueTypes"
*/container/@type)]/@type" />

With the root node as context, this is selecting all container elements in descendants of /ead/archdesc/dsc whose type is not the same as that of a container *child* of a following element.

So, while following siblings are indeed found on the following:: axis, this in fact is checking elements against nieces (and/or nephews) or cousins (at various removes), but not against siblings.


On 4/26/2012 2:15 PM, Michele R Combs wrote:
Do I put this at the top, where it is now? I tried it there and it tells me

Element:<xsl:name> must not appear directly within xsl:stylesheet

(Sorry if this should be obvious...)

-----Original Message-----
From: Martin Honnen [mailto:Martin.Honnen@xxxxxx]
Sent: Thursday, April 26, 2012 1:48 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re: [xsl] Help parsing a node

Michele R Combs wrote:
Pretty sure they're using 1.0 but I can check.

Define a key

<xsl:name name="uniqueTypesKey"
use="@type" />

and then the variable as

<xsl:variable name="uniqueTypes"
select="ead/archdesc/dsc/descendant::*/container[generate-id() = generate-id(key('uniqueTypesKey', @type)[1])]"/>

-- ====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. 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