Tony wrote:

> Hi all.

>

> I'll explain what we're doing first by way of an example before asking

> about the XSLT.

>

> We order 10 pallets of ABC and 20 pallets of XYZ.

> 10 X ABC costs $XXX and 20 X XYZ costs $YYY.

> In the confirmation we get back from the supplier we get the order

> back plus extra data that we need but it occurs more than once.

>

> So the confirmation comes back with:

> 10 X ABC = $XXX

> 20 X XYZ = $YYY

> 10 X pallet = $10

> 20 X pallet = $20
They *charge* you for the pallets?

> Each of these items comes back as an <OrderLine /> with specific

> details attached, like weight, unit price, currency, product number,

> etc)
This looks like a classical piece of accountants' XML. Unfortunately

some of the people working on systems like this need some significantly

better training. Better still, keep the accountants well away from the

markup if you can

> I need to translate the incoming order confirmation using XSLT into

> OrderLines based on the product number (only 1 per orderline),

> checking that the unit price is the same.
Without seeing the markup, I can only guess at what you mean. Let's

assume you have something like

<order>

<orderline q="10" prod="ABC" unit="5"/>

<orderline q="20" prod="XYZ" unit="10"/>

<orderline q="10" prod="pallet" unit="1"/>

<orderline q="20" prod="pallet" unit="1"/>

</order>

> eg. In the above example the pallets would have the same product

> number and same unit price ($1 each) therefore they would be appended

> to make 30 X pallet = $30.

>

> ie. I need a document that comes back with:

>

> 10 X ABC = $XXX

> 20 X XYZ = $YYY

> 30 X pallet = $30

>

> I've tried various means even grouping but it just doesn't seem to

> work.
<xsl:template match="order">

<order>

<xsl:apply-templates/>

</order>

</xsl:template>

<xsl:template match="orderline">

<xsl:if test="count(following-sibling:

rderline)=0 or

following-sibling:

rderline/@prod!=current()/@prod">

<orderline prod="{@prod}" unit="{@unit}">

<xsl:attribute name="q">

<xsl:value-of

select="sum(../orderline[@prod=current()/@prod]/@q)"/>

</xsl:attribute>

</orderline>

</xsl:if>

</xsl:template>

///Peter