xsl-list
[Top] [All Lists]

Re: [xsl] Getting a specific element count from a generic match

2006-04-07 19:31:10
Good one, Mike, and thanks for reminding me about distinct-values().

Jay Bryant
Bryant Communication Services

----- Original Message ----- 
From: "Michael Kay" <mike(_at_)saxonica(_dot_)com>
To: <xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com>
Sent: Friday, April 07, 2006 3:13 PM
Subject: RE: [xsl] Getting a specific element count from a generic match



<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>

  <xsl:variable name="namelist" select="//*[not(name() =
following::*/name())]"/>


We're talking 2.0 here: you can get all the distinct names using

select="distinct-values(//*/node-name())"

That's O(n log n) rather than O(n^2), and it's also namespace-aware.

Michael Kay
http://www.saxonica.com/



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: 
<mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--