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

RE: Getting max/min numbers out of nested structure

Subject: RE: Getting max/min numbers out of nested structure
From: Michele R Combs <mrrothen@xxxxxxx>
Date: Mon, 10 Jun 2013 15:47:16 +0000
RE:  Getting max/min numbers out of nested structure
I figured it was easy but I didn't think it would be THAT easy -- thanks.

Michele

-----Original Message-----
From: Michael Kay [mailto:mike@xxxxxxxxxxxx]
Sent: Monday, June 10, 2013 11:42 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Getting max/min numbers out of nested structure

What's wrong with

<xsl:for-each select="//a">
  <xsl:value-of select="min(.//box), max(.//box)"/> </xsl:for-each>

Michael Kay


On 10 Jun 2013, at 16:35, Michele R Combs wrote:

> Given this nested structure (hope it comes through legibly):
>
> <a>
>      <b>
>           <box>1</box>
>           <box>1</box>
>      </b>
>      <b>
>           <box>1</box>
>           <box>2</box>
>           <c>
>                <box>2</box>
>                <box>2</box>
>           </c>
>      </b>
> </a>
> <a>
>      <b>
>           <box>3</box>
>           <box>4</box>
>           <c>
>                <box>6</box>
>                <box>6</box>
>           </c>
>           <box>5</box>
>           <box>5</box>
>      </b>
>      <b>
>           <box>5</box>
>           <box>5</box>
>      </b>
> </a>
>
> What is the easiest way to find the max/min box numbers in each <a>?  That
is, for the first <a> I want "1-2" and for the second <a> I want "3-6."  FYI,
in the real data, rather than stopping at three nested levels (a, b, c) it can
potentially go up to 12 (!!).  Normally I would simply grab the value from the
first descendant and the value from the last descendant, but it turns out that
sometimes the numbers aren't in order within the document tree (as shown in
the second <a>) so that's not reliable enough.
>
> Thanks --
>
> Mich

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.