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 May 1st, 2008, 10:06 AM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default XSLT Help to get value from Upper Node by compare

I am basic user and having problems reading the value from the upper node. Like i explain below, How to compare value with the 2level above the context with the present value and get populated at the present level.

I guess, i did something wrong with my explanation i hope

I am trying compare

../../Item/ID=BusinessTransactionDocumentReference/ItemID

These two and get the following field from ITEM node

../../Item/Product/InternalID

Description

At the Handling Units , i am writing all values by looping, Based on BusinessTransactionDocumentReference/ItemID , i go up 2 levels and get the matching value

<PedDrugName>
<xsl:value-of select="../../Item/Product/InternalID=BusinessTransactionDocumentReference/ItemID"/>
</PedDrugName>

I have 3 fields like these
<PedManufacturer>
<xsl:value-of select="../../Item/Product/VendorID"/>
</PedManufacturer>
<PedProductCode><xsl:text>SAP PedProductCode</xsl:text>
<Code>
<xsl:value-of select="BusinessTransactionDocumentReference/ItemID"/>
</Code>
</PedProductCode>

One more Sub node, i need to get 2 more fields like the above
<PedItemInfo>
<PedLot>
<xsl:value-of select="../Item/Batch/InternalID"/>
</PedLot>
<PedExpirationDate>
this will be current date
</PedExpirationDate>

Attaching XSLT Map, with Source and an Example of Output.
 
Old May 1st, 2008, 10:25 AM
joefawcett's Avatar
Wrox Author
 
Join Date: Jun 2003
Posts: 3,074
Thanks: 1
Thanked 38 Times in 37 Posts
Default

Attachments not allowed. Can you show an example of input etc?

--

Joe (Microsoft MVP - XML)
 
Old May 1st, 2008, 10:36 AM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default




        <Item>
            <ID>900001</ID>
            <SchedulingAgreementReference>
                <ID>TEST BATCH SPLIT 03</ID>
                <ItemID/>
            </SchedulingAgreementReference>
            <BuyerParty>
                <InternalID schemeAgencyID="SAPD02_050">1034</InternalID>
            </BuyerParty>
            <Product>
                <InternalID schemeAgencyID="SAPD02_050">061230490</InternalID>
                <StandardID>00300746123903</StandardID>
            </Product>
            <Batch>
                <InternalID>55003A3</InternalID>
            </Batch>
            <Quantity unitCode="EA">24.000</Quantity>
        </Item>
        <Item>
            <ID>900002</ID>
            <SchedulingAgreementReference>
                <ID>TEST BATCH SPLIT 03</ID>
                <ItemID/>
            </SchedulingAgreementReference>
            <BuyerParty>
                <InternalID schemeAgencyID="SAPD02_050">1034</InternalID>
            </BuyerParty>
            <Product>
                <InternalID schemeAgencyID="SAPD02_050">061230490</InternalID>
                <StandardID>00300746123903</StandardID>
            </Product>
            <Batch>
                <InternalID>54218A2</InternalID>
            </Batch>
            <Quantity unitCode="EA">24.000</Quantity>
        </Item>
        <HandlingUnit>
            <ID>00000000003000012603</ID>
            <AlternativeID>$15</AlternativeID>
            <ElectronicLabel>
                <ID>urn:epc:id:sscc:030074.10000000265</ID>
                <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000266</HierarchicalParentID>
                <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sscc-96:2.030074.10000000265</EncodingSchemeDecodedID>
                <EncodingSchemeEncodedID SchemeID="EPC_1.30">31581D5E82540BE509000000</EncodingSchemeEncodedID>
                <PhysicalItemReferenceID>00000000003000012603</PhysicalItemReferenceID>
                <PhysicalItemReferenceTypeCode>SSCC</PhysicalItemReferenceTypeCode>
                <PhysicalItemSerialID>103007400000002652</PhysicalItemSerialID>
            </ElectronicLabel>
            <LoadCarrier>
                <Product>
                    <InternalID>RFID_CASE</InternalID>
                </Product>
            </LoadCarrier>
            <HeightMeasure unitCode="">0.000</HeightMeasure>
            <LengthMeasure unitCode="">0.000</LengthMeasure>
            <WidthMeasure unitCode="">0.000</WidthMeasure>
            <GrossVolumeMeasure unitCode="FTQ">0.001</GrossVolumeMeasure>
            <NetVolumeMeasure unitCode="FTQ">0.001</NetVolumeMeasure>
            <GrossWeightMeasure unitCode="LBR">0.100</GrossWeightMeasure>
            <NetWeightMeasure unitCode="LBR">0.100</NetWeightMeasure>
            <Load>
                <BusinessTransactionDocumentReference>
                    <ItemID>900001</ItemID>
                </BusinessTransactionDocumentReference>
                <Quantity unitCode="EA">12.000</Quantity>
                <ElectronicLabel>
                    <ID>urn:epc:id:sgtin:030074.0612390.1411</ID>
                    <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000265</HierarchicalParentID>
                    <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sgtin-96:1.030074.0612390.1411</EncodingSchemeDecodedID>
                    <EncodingSchemeEncodedID SchemeID="EPC_1.30">30381D5E8256098000000583</EncodingSchemeEncodedID>
                    <PhysicalItemReferenceID>$39</PhysicalItemReferenceID>
                    <PhysicalItemProduct>
                        <StandardID>00300746123903</StandardID>
                    </PhysicalItemProduct>
                </ElectronicLabel>
                <ElectronicLabel>
                    <ID>urn:epc:id:sgtin:030074.0612390.1422</ID>
                    <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000265</HierarchicalParentID>
                    <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sgtin-96:1.030074.0612390.1422</EncodingSchemeDecodedID>
                    <EncodingSchemeEncodedID SchemeID="EPC_1.30">30381D5E825609800000058E</EncodingSchemeEncodedID>
                    <PhysicalItemReferenceID>$41</PhysicalItemReferenceID>
                    <PhysicalItemProduct>
                        <StandardID>00300746123903</StandardID>
                    </PhysicalItemProduct>
                </ElectronicLabel>

            </Load>
            <Load>
                <BusinessTransactionDocumentReference>
                    <ItemID>900002</ItemID>
                </BusinessTransactionDocumentReference>
                <Quantity unitCode="EA">12.000</Quantity>
                <ElectronicLabel>
                    <ID>urn:epc:id:sgtin:030074.0612390.1436</ID>
                    <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000265</HierarchicalParentID>
                    <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sgtin-96:1.030074.0612390.1436</EncodingSchemeDecodedID>
                    <EncodingSchemeEncodedID SchemeID="EPC_1.30">30381D5E825609800000059C</EncodingSchemeEncodedID>
                    <PhysicalItemReferenceID>$1</PhysicalItemReferenceID>
                    <PhysicalItemProduct>
                        <StandardID>00300746123903</StandardID>
                    </PhysicalItemProduct>
                </ElectronicLabel>
            </Load>
        </HandlingUnit>
        <HandlingUnit>
            <ID>00000000003000012604</ID>
            <AlternativeID>$16</AlternativeID>
            <ElectronicLabel>
                <ID>urn:epc:id:sscc:030074.10000000264</ID>
                <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000266</HierarchicalParentID>
                <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sscc-96:2.030074.10000000264</EncodingSchemeDecodedID>
                <EncodingSchemeEncodedID SchemeID="EPC_1.30">31581D5E82540BE508000000</EncodingSchemeEncodedID>
                <PhysicalItemReferenceID>00000000003000012604</PhysicalItemReferenceID>
                <PhysicalItemReferenceTypeCode>SSCC</PhysicalItemReferenceTypeCode>
                <PhysicalItemSerialID>103007400000002645</PhysicalItemSerialID>
            </ElectronicLabel>
            <LoadCarrier>
                <Product>
                    <InternalID>RFID_CASE</InternalID>
                </Product>
            </LoadCarrier>
            <HeightMeasure unitCode="">0.000</HeightMeasure>
            <LengthMeasure unitCode="">0.000</LengthMeasure>
            <WidthMeasure unitCode="">0.000</WidthMeasure>
            <GrossVolumeMeasure unitCode="FTQ">0.001</GrossVolumeMeasure>
            <NetVolumeMeasure unitCode="FTQ">0.001</NetVolumeMeasure>
            <GrossWeightMeasure unitCode="LBR">0.100</GrossWeightMeasure>
            <NetWeightMeasure unitCode="LBR">0.100</NetWeightMeasure>
            <Load>
                <BusinessTransactionDocumentReference>
                    <ItemID>900001</ItemID>
                </BusinessTransactionDocumentReference>
                <Quantity unitCode="EA">12.000</Quantity>
                <ElectronicLabel>
                    <ID>urn:epc:id:sgtin:030074.0612390.1410</ID>
                    <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000264</HierarchicalParentID>
                    <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sgtin-96:1.030074.0612390.1410</EncodingSchemeDecodedID>
                    <EncodingSchemeEncodedID SchemeID="EPC_1.30">30381D5E8256098000000582</EncodingSchemeEncodedID>
                    <PhysicalItemReferenceID>$27</PhysicalItemReferenceID>
                    <PhysicalItemProduct>
                        <StandardID>00300746123903</StandardID>
                    </PhysicalItemProduct>
                </ElectronicLabel>

            </Load>
            <Load>
                <BusinessTransactionDocumentReference>
                    <ItemID>900002</ItemID>
                </BusinessTransactionDocumentReference>
                <Quantity unitCode="EA">12.000</Quantity>
                <ElectronicLabel>
                    <ID>urn:epc:id:sgtin:030074.0612390.1434</ID>
                    <HierarchicalParentID>urn:epc:id:sscc:030074.10000 000264</HierarchicalParentID>
                    <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sgtin-96:1.030074.0612390.1434</EncodingSchemeDecodedID>
                    <EncodingSchemeEncodedID SchemeID="EPC_1.30">30381D5E825609800000059A</EncodingSchemeEncodedID>
                    <PhysicalItemReferenceID>$3</PhysicalItemReferenceID>
                    <PhysicalItemProduct>
                        <StandardID>00300746123903</StandardID>
                    </PhysicalItemProduct>
                </ElectronicLabel>

            </Load>
        </HandlingUnit>
        <HandlingUnit>
            <ID>00000000003000012605</ID>
            <AlternativeID>$14</AlternativeID>
            <ElectronicLabel>
                <ID>urn:epc:id:sscc:030074.10000000266</ID>
                <EncodingSchemeDecodedID SchemeID="EPC_1.30">urn:epc:tag:sscc-96:0.030074.10000000266</EncodingSchemeDecodedID>
                <EncodingSchemeEncodedID SchemeID="EPC_1.30">31181D5E82540BE50A000000</EncodingSchemeEncodedID>
                <PhysicalItemReferenceID>00000000003000012605</PhysicalItemReferenceID>
                <PhysicalItemReferenceTypeCode>SSCC</PhysicalItemReferenceTypeCode>
                <PhysicalItemSerialID>103007400000002669</PhysicalItemSerialID>
            </ElectronicLabel>
            <LoadCarrier>
                <Product>
                    <InternalID>RFID_PALL</InternalID>
                </Product>
            </LoadCarrier>
            <HeightMeasure unitCode="">0.000</HeightMeasure>
            <LengthMeasure unitCode="">0.000</LengthMeasure>
            <WidthMeasure unitCode="">0.000</WidthMeasure>
            <GrossVolumeMeasure unitCode="FTQ">0.003</GrossVolumeMeasure>
            <NetVolumeMeasure unitCode="FTQ">0.003</NetVolumeMeasure>
            <GrossWeightMeasure unitCode="LBR">0.300</GrossWeightMeasure>
            <NetWeightMeasure unitCode="LBR">0.300</NetWeightMeasure>
            <LowerLevelHandlingUnit>
                <ID>00000000003000012604</ID>
            </LowerLevelHandlingUnit>
            <LowerLevelHandlingUnit>
                <ID>00000000003000012603</ID>
            </LowerLevelHandlingUnit>
        </HandlingUnit>
    </Delivery>
</ns1:DespatchedDeliveryNotification>

 
Old May 1st, 2008, 10:38 AM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I stripped some of them.

I have 4 Item Nodes and Three HandlingUnit Nodes.

I start with HandlingUnit and writing all the values, in between by comparing the value from HandlingUnit with Item/ID and get the Product/InternalID

I appreciate your help in advance.

 
Old May 1st, 2008, 10:54 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

Conditions in XSLT (which are called Predicates) are written like this:

node-list[condition]

or

node-list[position]

condition will be relative to the current node-list being selected, so if you want to list all elements with children called 'child' who's text value is each to 'A' then it would look like:

node-list[child='A']

In your example its not clear the relationship between Item and BusinessTransationDocumentReference, but comething like the following might work:

<PedDrugName>
<xsl:value-of select="../../Item/Product/InternalID[. = current()/BusinessTransactionDocumentReference/ItemID]"/>
</PedDrugName>

However this will just output the text value of the InternalID, which will be same as the BusinessTransactionDocumentReference/ItemID.


/- Sam Judson : Wrox Technical Editor -/
 
Old May 1st, 2008, 10:59 AM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Might this explains better

I am trying compare
Which are the same values from different nodes like Item (Upper Level) & HandlingUnit (LowerLevvel)
../../Item/ID=BusinessTransactionDocumentReference/ItemID

These two and get the following field from ITEM node

../../Item/Product/InternalID

 
Old May 1st, 2008, 11:02 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

so something like

../../Item[ID=current()/BusinessTransactionDocumentReference/ItemID]/Product/InternalID

This assumes you are currently processing the Load element.

/- Sam Judson : Wrox Technical Editor -/
 
Old May 1st, 2008, 11:06 AM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I am currently at HandlingUnit Context. Item will be above

Item 0:N
HandlingUnit 0:N

I tried with the following syntax, no value returns from Item/Product/InternalID

<xsl:value-of select="../../Item/Product/InternalID[ID = current()/BusinessTransactionDocumentReference/ItemID]"/>

 
Old May 1st, 2008, 11:10 AM
samjudson's Avatar
Friend of Wrox
 
Join Date: Aug 2007
Posts: 2,128
Thanks: 1
Thanked 189 Times in 188 Posts
Default

If you are at the HandlingUnit element, how do you know which BusinessTransactionDocumentReference you should be referring to?

Basically you just need to change the second part to refer to whichever element you want (the following will not produce the output you want, but might help you on your way):

<xsl:value-of select="../../Item/Product/InternalID[ID = current()/Load/BusinessTransactionDocumentReference/ItemID]"/>

/- Sam Judson : Wrox Technical Editor -/
 
Old May 1st, 2008, 11:32 AM
Authorized User
 
Join Date: Dec 2007
Posts: 31
Thanks: 0
Thanked 0 Times in 0 Posts
Default

It worked. Sorry, i am at the Load level actually. Thanks for your help.

<xsl:value-of select="../../Item[ID=current()/BusinessTransactionDocumentReference/ItemID]/Product/InternalID"/>

I am also able to get all other fields like below

<xsl:value-of select="../../Item[ID=current()/BusinessTransactionDocumentReference/ItemID]/Product/VendorID"/>
<xsl:value-of select="../../Item[ID=current()/BusinessTransactionDocumentReference/ItemID]/Batch/InternalID"/>

<xsl:value-of select="../../HandlingUnit[ID=current()/ID]/ElectronicLabel/EncodingSchemeDecodedID"/>










Similar Threads
Thread Thread Starter Forum Replies Last Post
Compare current value with previous parent node ratjetoes XSLT 2 July 17th, 2008 06:15 AM
XSLT Node add/delete aintvoguish XSLT 2 December 20th, 2007 03:01 AM
XML + XSLT Compare Nodes tommyready XSLT 5 September 5th, 2007 03:18 AM
modifying a node in xslt the rail dale XSLT 3 July 17th, 2007 09:15 AM
Compare two xml files using xslt sudha XSLT 0 March 10th, 2006 01:04 AM





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