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

Re: Recursive counting

Subject: Re: Recursive counting
From: "G. Ken Holman" <gkholman@xxxxxxxxxxxxxxxxxxxx>
Date: Tue, 18 Jul 2006 21:18:48 -0400
steve urn
At 2006-07-18 17:24 -0400, Steve wrote:
Well after success with my first recursive template I was all set to
make one of my own, but now shamefully am coming to the list for
advice over something that appears quite simple.

XML ------->

Desired output ------->
<!-- @count corresponds to number of times
the preference appeared among the list of <people> --->


Stipulation: --------->

<out>'s must be sorted alphabetically, regardless of <option> order.

I'm not sure why you are using recursion ... I hope the following helps. BTW, I think your desired output count was wrong for the third item.

. . . . . . . . . Ken

T:\ftemp>type steve.xml
<?xml version="1.0" encoding="US-ASCII"?>
    <o type="A">who</o>
    <o type="A">what</o>
    <o type="A">when</o>
    <o type="B">how</o>
    <o type="B">nexus</o>
    <o type="B">triumph</o>
    <o type="C">alligator</o>
    <o type="C">spurn</o>
    <person pref="who" />
    <person pref="nexus" />
    <person pref="how" />
    <person pref="alligator" />
    <person pref="spurn" />
    <person pref="triumph" />
    .... etc ....

T:\ftemp>type steve.xsl
<?xml version="1.0" encoding="US-ASCII"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

<xsl:output indent="yes"/>

<xsl:template match="/data">
  <xsl:variable name="people" select="people/person"/>
  <xsl:variable name="options" select="options/o"/>

    <xsl:for-each select="$options">
      <xsl:sort select="@type"/>
      <xsl:if test="generate-id(.)=
        <out type="{@type}"

T:\ftemp>xslt steve.xml steve.xsl con
<?xml version="1.0" encoding="utf-8"?>
<output xmlns:steve="urn:x-steve">
   <out type="A" count="1"/>
   <out type="B" count="3"/>
   <out type="C" count="2"/>

-- Registration open for UBL training: Montrial, Canada 2006-08-07 Also for XSL-FO/XSLT training: Minneapolis, MN 2006-07-31/08-04 Also for UBL/XML/XSLT/XSL-FO training: Varo,Denmark 06-09-25/10-06 World-wide corporate, govt. & user group UBL, XSL, & XML training. G. Ken Holman mailto:gkholman@xxxxxxxxxxxxxxxxxxxx Crane Softwrights Ltd. http://www.CraneSoftwrights.com/s/ Box 266, Kars, Ontario CANADA K0A-2E0 +1(613)489-0999 (F:-0995) Male Cancer Awareness Aug'05 http://www.CraneSoftwrights.com/s/bc Legal business disclaimers: http://www.CraneSoftwrights.com/legal

Current Thread


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.
First Name
Last Name
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.