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

match first occurrence for which a condition holds tru

Subject: match first occurrence for which a condition holds true
From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx>
Date: Thu, 6 Jan 2011 15:05:51 +0100
 match first occurrence for which a condition holds tru
Hi all,

i'm struggling a bit with following simplified use case. I have a subpart
which consists of 1 or more materialgroups and a materialgroup consists of 1
or more materials.  They all have a percentage (measured on subpart level).
Sometimes the sum of these percentages doesn't add up to 100% so the customer
wants me to correct the largest [first matching] percentage so that the total
percentages add up to 100.

I am able to match on the percentages which match the maximum in the context
of subpart but in example below i match on both lead and trioxide whereas i
only need to fix the first occurence which is lead in this case.

How can i solve this elegantly?

Kind regards,
Robby Pelssers

  <xsl:template
match="MassPercent[max(ancestor::subpart/materialgroup/material/percentage) =
.]" mode="fixpercentages">
    <percentage>fix me</percentage>
  </xsl:template>

<subpart>
  <materialgroup>
    <material name="lead">
      <percentage>35.30</percentage>
    </material>
  </materialgroup>
  <materialgroup>
    <material name="trioxide">
      <percentage>35.30</percentage>
    </material>
    <material name="Polybutylene">
      <percentage>20.50</percentage>
    </material>
  </materialgroup>
  <materialgroup>
    <material name="Glass Fibrous">
      <percentage>08.80</percentage>
    </material>
  </materialgroup>
</subpart>

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-2011 All Rights Reserved.