[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: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Mon, 10 Jun 2013 11:42:46 -0400
Re:  Getting max/min numbers out of nested structure
At 2013-06-10 15:35 +0000, Michele R Combs wrote:
Given this nested structure (hope it comes through legibly):
...
What is the easiest way to find the max/min box numbers in each <a>?

The easiest is to use XSLT 2 as shown below. I hope this helps.


. . . . . . Ken

t:\ftemp>type michele.xml
<?xml version="1.0" encoding="UTF-8"?>
<test>
  <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>
</test>

t:\ftemp>xslt2 michele.xml michele.xsl
1 - 2
3 - 6

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

<xsl:output method="text"/>

<xsl:template match="/">
  <xsl:for-each select="test/a">
    <xsl:value-of select="min(.//box),'-',max(.//box)"/>
    <xsl:text>&#xa;</xsl:text>
  </xsl:for-each>
</xsl:template>

</xsl:stylesheet>
t:\ftemp>



--
Contact us for world-wide XML consulting and instructor-led training |
Free 5-hour lecture: http://www.CraneSoftwrights.com/links/udemy.htm |
Crane Softwrights Ltd.            http://www.CraneSoftwrights.com/s/ |
G. Ken Holman                   mailto:gkholman@xxxxxxxxxxxxxxxxxxxx |
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers:    http://www.CraneSoftwrights.com/legal |

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.