Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old July 12th, 2007, 03:19 AM
Registered User
 
Join Date: Jul 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default PLease help me i am desperate

XML file
<Shipment SellerOrganizationCode="CARBONIZING" ShipmentNo="Shipment-1" >

<Containers>
  <Container Action="Create" ContainerScm="CC-1" ContainerType="Case">
      <ContainerDetails >
        <ContainerDetail Quantity="9.00" >
                         <ShipmentTagSerials>
                                                 <ShipmentTagSerial ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="9.00" LotNumber="5" LotAttribute1="Lot-1-11" LotAttribute2="Lot-1-12" />
                                                 </ShipmentTagSerials>
                         <ShipmentLine ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="9.00" />
        </ContainerDetail>
        </ContainerDetails>
      </Container>
<Container Action="Create" ContainerScm="CC-1" ContainerType="Case">
      <ContainerDetails >
        <ContainerDetail Quantity="9.00" >
                         <ShipmentTagSerials>
                                                 <ShipmentTagSerial ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="9.00" LotNumber="4" LotAttribute1="Lot-1-11" LotAttribute2="Lot-1-12" />
                                                 </ShipmentTagSerials>
                         <ShipmentLine ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="9.00" />
        </ContainerDetail>
        </ContainerDetails>
      </Container>
<Container Action="Create" ContainerScm="CC-1" ContainerType="Case">
      <ContainerDetails >
        <ContainerDetail Quantity="9.00" >
                         <ShipmentTagSerials>
                                                 <ShipmentTagSerial ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="9.00" LotNumber="5" LotAttribute1="Lot-1-11" LotAttribute2="Lot-1-12" />
                                                 </ShipmentTagSerials>
                         <ShipmentLine ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="9.00" />
        </ContainerDetail>
        </ContainerDetails>
      </Container>


              </Containers>

<ShipmentLines>
 <ShipmentLine Action="Create" ItemID="TagC" ProductClass="GOOD" UnitOfMeasure="EACH" Quantity="17.00"
 SegmentType="MTO" Segment="Order4" />
</ShipmentLines>
</Shipment>

Output should be increase the quantity in Containers having LotNo 5 by 1...

Please send me the code to [email protected]

 
Old July 12th, 2007, 04:11 AM
mhkay's Avatar
Wrox Author
 
Join Date: Apr 2004
Posts: 4,962
Thanks: 0
Thanked 292 Times in 287 Posts
Default

A couple of points about protocol.

First, it's a good idea to use a subject line that describes your problem, not your degree of desperation. Other users will be searching the archives to look for problems similar to their own, not for users with a similar level of panic.

Secondly, please don't ask for solutions to be emailed to you directly. If you want a private solution, you can pay for it. A forum like this is for the mutual benefit of the community.

It's actually a bad idea to say that the problem is urgent. Many people will decide (from experience) that if you're in that much of a hurry, you won't take time to study the solution that's offered, and will come back 10 minutes after getting a response with a demand for further help to get it working.

The way to make a small change to a document, while copying everything else, is to have a template rule that copies elements:

<xsl:template match="*">
 <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

and then override it with a more selective template that changes the elements you want to change. In your case I'm not entirely clear on the requirement, because you have quantities in lots of different places. But if we assume that it's the ShipmentTagSerial quantity that you want to change, you can do it like this:

<xsl:template match="ShipmentTagSerial[@LotNumber=5]">
 <xsl:copy>
  <xsl:copy-of select="@*"/>
  <xsl:attribute name="Quantity">
    <xsl:value-of select="@Quantity + 1"/>
  </xsl:attribute>
  <xsl:apply-templates/>
 </xsl:copy>
</xsl:template>

Michael Kay
http://www.saxonica.com/
Author, XSLT Programmer's Reference and XPath 2.0 Programmer's Reference





Similar Threads
Thread Thread Starter Forum Replies Last Post
Desperate for an answer kase_just .NET Framework 2.0 0 October 5th, 2007 06:54 PM
desperate newbie lookig for help .... usmanlakhani Classic ASP Components 1 May 1st, 2005 05:10 AM
Desperate need of help... Mrarmbars BOOK: Beginning PHP4/PHP 5 ISBN: 978-0-7645-4364-7; v5 ISBN: 978-0-7645-5783-5 1 November 18th, 2004 06:24 PM
Simple question Desperate for help!! Raif ASP.NET 1.0 and 1.1 Basics 4 August 7th, 2004 11:55 AM
=Date() Problem - I am desperate umagrama Access VBA 4 December 5th, 2003 09:31 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.