|
Subject: [xsl] match first occurrence for which a condition holds true From: "Robby Pelssers" <robby.pelssers@xxxxxxxxx> Date: Thu, 6 Jan 2011 15:05:51 +0100 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| Re: [xsl] sort problem, Terry Ofner | Thread | Re: [xsl] match first occurrence fo, David Carlisle |
| Re: [xsl] replacing nodes during xs, Martin Honnen | Date | Re: [xsl] replacing nodes during xs, David Carlisle |
| Month |