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>
</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(_at_)CraneSoftwrights(_dot_)com
|
Google+ profile: https://plus.google.com/116832879756988317389/about |
Legal business disclaimers: http://www.CraneSoftwrights.com/legal |
--~------------------------------------------------------------------
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>
--~--