xsl uniq,xsl sort uniq,uniq templates,template uniq, xml%%%xsl uniq - Re: sort

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

Re: sort | uniq via keys

Subject: Re: sort | uniq via keys
From: Saverio Perugini <sperugin@xxxxxxxxxxxxxxxx>
Date: Thu, 14 Feb 2002 15:30:17 -0500 (EST)
xsl uniq
On Thu, 14 Feb 2002, Wendell Piez wrote:

> Using the following:: axis on your for-each, you are selecting nodes from
> those following your context node, the '/db' you have matched on.
>
> But your db is your document element, and has no following nodes.
>
> Just select your descendants (select="descendant::*[...]) and it should work.

Thank you Wendell.

I am curious then as to the difference b/t the descendant, following,
and following-sibling axes.

In addition, consider the following problem.  Instead of sorting and uniqing the
element names of `all' nodes in the input tree, I'd like to extract
the names of elements residing at the same `level' in the input tree, assuming a
balanced input tree.

e.g.,

in the following data

<db>
   <a>
      <d>
         <j>...</j>
         <k>...</k>
      </d>
      <e>
         <l>...</l>
         <m>...</m>
      </e>
   </a>
   <b>
      <f>
         <n>...</n>
         <o>...</o>
      </f>
      <g>
         <p>...</p>
         <q>...</q>
      </g>
   </b>
   <c>
      <h>
         <r>...</r>
         <s>...</s>
      </h>
      <i>
         <t>...</t>
         <u>...</u>
      </i>
   </c>
</db>

I would like the following output,

first level
-----------
a b c

second level
------------
d e f g h i

third level
-----------
j k l m n o p q r s t u

The following is my initial solution.

<xsl:template match="/db" priority="0.7">
   <xsl:apply-templates select="*[1]"/>
</xsl:template>

<xsl:template match="*">

   <xsl:for-each select="following-sibling::*">
      <xsl:sort select="name()"/>
      <xsl:value-of value="name()" />
  </xsl:for-each>

  <xsl:apply-templates select="*[1]"/>

</xsl:template>

<xsl:template match="text()"/>

This runs down the left-most path of the tree and collects siblings.
The problem is that is works at the sibling level, while I am
interested in an `entire' level in the tree.

Thank You and Best Regards,

Saverio Perugini


 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.