I have the attached the XML file along with this mail and also the code-block is pasted below.
If you check the xml tree in the XML file, the tree structure is like the following:
(1)Invoice->InvoiceHeader->InvoiceSiteSet->InvoiceSite(multiple numbers of this node is present)
(2)Unvoice->InvoiceDetail->InvoiceLineSet->InvoiceLine(multiple numbers of this node is present)
What i want is to loop through the InvoiceSite nodes and retrieve the SiteId(an attribute of InvoiceSite) and use that id to retrieve matching records from InvoiceLine nodes(the attribute11 of this node).
But in the loop i am not able to retrieve the records from the InvoiceLine nodes.If i tyry to retrieve the InvoiceLine node after the loop is over, i am able to get the records i want.
Code Snippet of the for-loop i am talking above
Code:
<xsl:template match="Invoice" mode="mode1">
<table border="0" width="100%">
<xsl:for-each select="./InvoiceHeader/InvoiceSiteSet/InvoiceSite[@SiteType='FACTORY_ADDRESS']">
<tr>
<td width="10%"><b>Name:</b></td>
<td><xsl:value-of select="@SiteName"/></td>
</tr>
<tr>
<td><b>Address:</b></td><td><xsl:value-of select="concat(./Address/@Line1,',',./Address/@City,',',./Address/@PostalCode,',',./Address/@Country)"/></td>
</tr>
<tr>
<td><b>Lot#(s):</b></td>
<td>
<xsl:value-of select="./InvoiceDetail/InvoiceLineSet/InvoiceLine[1]/@Attribute11"/>[This is the line of code not retrieving the records from Invoicedetail]
</td>
</tr>
</xsl:for-each>
</table>
</xsl:template>
XML FILE
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="Invoice.xsl"?>
<Invoice>
<InvoiceHeader InvoiceId="10982" InvoiceNumber="700008-0010982" Revision="000" InvoiceType="COMMERCIAL INVOICE" ContractId="216126" ContractNumber="0701934" InvoiceDate="2007-12-07" InvoiceStatus="Generated" InvoiceStatusDate="2007-12-07" IsShipmentActive="True" CreationDate="2007-12-06" GenerateDate="2007-12-07" VesselName="VESSEL XML" VoyageNumber="VOYAGE XML" CountryOfOrigin="ITALY" PortOfEntry="CHARLOTTE" TermsOfSale="FOB - NYK LOGISTICS (HONG KONG) LTD. TORONTO CANADA" TermsOfPayment="OPEN ACCOUNT DOCUMENT INSTRUCTION" CurrencyCode="USD" Amount1="81813.6" Amount2="" Amount3="" TotalAmount="49424.14" Comments="FOLLOWING ITEM COULD NOT BE FOUND FROM CONTRACT PROVIDED:#xD;#xA;LOT# 0308 EYE SHADOW#xD;#xA;HTS#3304.20.0000#xD;#xA;FOB VALUE: 16.80#xD;#xA;UNIT PRICE: 16.80 X QTY: 160#xD;#xA;ENXTENDED $2688.00#xD;#xA;#xD;#xA;TOTAL AMOUNT DIFFERENCE FROM SAMPLE AND THIS INVOICE:#xD;#xA;$49424.14 + 2688.00#xD;#xA;=$52112.14 (Total Invoice AMount in Sample)" Case1Type="CARTON" Case1Count="11" Case2Type="" Case2Count="" Case3Type="" Case3Count="" CancelReason="" TermsTypeCode="" TermsDescription="" TermsBasisDateCode="" TermsDiscountPercent="" TermsDiscountDueDate="" TermsDiscountDaysDue="" TermsNetDueDate="" TermsDiscountAmount="" TermsNetDaysDue="" TermsDiscountBasisAmount="" TermsTotalDiscountAmount="" TermsNetAmountAfterDiscount="" AdjustedSacHeaderAmount="" AdjustedSacTotalAmount="" FreightTermsCode="" FobCode="" GroupKey="" VersionNumber="3.0" Attribute2="COSMETICS" Attribute3="453" Attribute4="RT" Attribute5="487821" Attribute6="15-MAR-2007" Attribute7="9484-7" Attribute8="DAJCPC" Attribute9="PLI THROUGH SELLER" Attribute10="ADA0000510, ADA0000511, ADA0000512, ADA0000513, ADING00101" Attribute11="32389.46" Attribute12="2.0" Attribute13="N" Attribute14="MVAN3" Attribute15="FOB" Attribute16="CHARLOTTE">
<InvoiceSiteSet Count="7">
<InvoiceSite SiteId="12499" SiteName="JCPENNY PURCHASING CORPORATION" CustomerSiteCode="JCP" SiteType="BUYER_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12499" Name="JCPENNY PURCHASING CORPORATION" Line1="5401 LEGACY DRIVE, " Line2="" Line3="" Line4="" City="PLANO" PostalCode="75024-3698" County="" State="TX" Province="" Country="USA" />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
</InvoiceSite>
<InvoiceSite SiteId="12500" SiteName="CARGO COSMETICS" CustomerSiteCode="EXT-3471" SiteType="VENDOR_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12500" Name="CARGO COSMETICS" Line1="120-1440 DON MILLS ROAD" Line2="" Line3="" Line4="" City="TORONTO" PostalCode="M3B 3M1" County="" State="ON" Province="" Country="CANADA" />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="508-555-4444" Fax="" Email="" Name=" XML DUMMY SUPPLIER" Key1="" ContactType="" />
</InvoiceSite>
<InvoiceSite SiteId="12501" SiteName="INTERCOS SPA" CustomerSiteCode="EXT-20813" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12501" Name="INTERCOS SPA" Line1="VIA S TECLA" Line2="" Line3="" Line4="" City="MILANO ITALY" PostalCode="3-20122" County="" State="" Province="" Country="ITALY" />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
</InvoiceSite>
<InvoiceSite SiteId="12502" SiteName="NK COSMETICS" CustomerSiteCode="EXT-20814" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12502" Name="NK COSMETICS" Line1="22 MELANIE DRIVE" Line2="UNITS 8 & 9" Line3="BRAMPTON" Line4="" City="ONTARIO CANADA" PostalCode="L6T4K9" County="" State="" Province="" Country="CANADA" />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
</InvoiceSite>
<InvoiceSite SiteId="12503" SiteName="CLAMAR COSMETICS INC" CustomerSiteCode="EXT-20815" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12503" Name="CLAMAR COSMETICS INC" Line1="1060 SALK ROAD UNIT 4 & 5" Line2="" Line3="PICKERING" Line4="" City="ONTARIO CANADA" PostalCode="L1W3X9" County="" State="" Province="" Country="CANADA" />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
</InvoiceSite>
<InvoiceSite SiteId="12504" SiteName="OXYGEN DEVELOPMENT" CustomerSiteCode="EXT-20816" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12504" Name="OXYGEN DEVELOPMENT" Line1="1441 WEST NEWPORT CENTER DRIVE" Line2="" Line3="" Line4="" City="DEERFIELD BEACH" PostalCode="33442" County="" State="FL" Province="" Country="U.S.A." />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
</InvoiceSite>
<InvoiceSite SiteId="12505" SiteName="SCHWAN STABILO COSMETICS" CustomerSiteCode="EXT-20817" SiteType="FACTORY_ADDRESS" CustomerSiteCodeDisplay="" Key1="" OrderSequence="">
<Address AddressId="12505" Name="SCHWAN STABILO COSMETICS" Line1="PRUMYSLOVA" Line2="SCHWANGWEG 1" Line3="CESKY PRUMLOV" Line4="" City="CZECH REPUBLIC" PostalCode="76-CZ38101" County="" State="" Province="" Country="CZECH REPUBLIC" />
<InvoiceContact ContactId="" Title="" FirstName="" LastName="" JobTitle="" PrimaryRole="" Phone="" Fax="" Email="" Name="" Key1="" ContactType="" />
</InvoiceSite>
</InvoiceSiteSet>
<SacSet Count="2">
<Sac SacId="7315" DocumentId="10982" PoId="216126" LineId="" SacType="INV" Description="PLI from contract" RecordNumber="PLI" OrderSequence="1" Indicator="N" TypeCode="PLI" Amount="0" Percent="0" PercentQualifier="" Rate="" Quantity="" QuantityUOM="" HandlingCode="" CanRemove="False" CanEdit="False" />
<Sac SacId="7355" DocumentId="10982" PoId="216126" LineId="" SacType="INV" Description="OTHER DEDUCTION" RecordNumber="" OrderSequence="" Indicator="N" TypeCode="OTHER" Amount="32389.46" Percent="" PercentQualifier="" Rate="" Quantity="" QuantityUOM="" HandlingCode="" CanRemove="True" CanEdit="True" />
</SacSet>
</InvoiceHeader>
<InvoiceDetail>
<InvoiceLineSet Count="11">
<InvoiceLine InvoiceLineId="17725" ItemType="LINE" LineId="" OrderSequence="1" Key1="PICKPACK-0302.01.100000412708.03120731" ItemDescription="LIQUID FOUNDATION" Quantity="1428" QuantityUOM="EA" UnitPrice="16.8" Amount1="23990.4" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0302" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="IT" Attribute9="RT" Attribute11="12501" Attribute12="16.8" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIQUID FOUNDATION#xA;HTS #:3304.99.5000#xA;ORIGIN:ITALY#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17726" ItemType="LINE" LineId="" OrderSequence="2" Key1="PICKPACK-0309.01.100000412708.03120731" ItemDescription="EYE SHADOW" Quantity="480" QuantityUOM="EA" UnitPrice="9.6" Amount1="4608" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0309" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="9.6" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="EYE SHADOW#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17727" ItemType="LINE" LineId="" OrderSequence="3" Key1="PICKPACK-0311.01.100000412708.03120731" ItemDescription="GLITTER" Quantity="160" QuantityUOM="EA" UnitPrice="15" Amount1="2400" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0311" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12503" Attribute12="15" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="GLITTER#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17728" ItemType="LINE" LineId="" OrderSequence="4" Key1="PICKPACK-0312.01.100000412708.03120731" ItemDescription="LIPSTICK" Quantity="1521" QuantityUOM="EA" UnitPrice="12" Amount1="18252" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0312" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="12" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIPSTICK#xA;HTS #:3304.10.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17729" ItemType="LINE" LineId="" OrderSequence="5" Key1="PICKPACK-0314.01.100000412708.03120731" ItemDescription="BLUSH" Quantity="160" QuantityUOM="EA" UnitPrice="15.6" Amount1="2496" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0314" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="US" Attribute9="RT" Attribute11="12504" Attribute12="15.6" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="BLUSH#xA;HTS #:9801.00.1097#xA;ORIGIN:U.S.A.#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17730" ItemType="LINE" LineId="" OrderSequence="6" Key1="PICKPACK-0320.01.100000412708.03120731" ItemDescription="LIP PENCIL" Quantity="160" QuantityUOM="EA" UnitPrice="8.4" Amount1="1344" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0320" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CZ" Attribute9="RT" Attribute11="12505" Attribute12="8.4" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIP PENCIL#xA;HTS #:3304.10.0000#xA;ORIGIN:CZECH REPUBLIC#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17731" ItemType="LINE" LineId="" OrderSequence="7" Key1="PICKPACK-0330.01.100000412708.03120731" ItemDescription="LIP GLOSS" Quantity="840" QuantityUOM="EA" UnitPrice="9.6" Amount1="8064" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0330" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="9.6" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="LIP GLOSS#xA;HTS #:3304.10.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17732" ItemType="LINE" LineId="" OrderSequence="8" Key1="PICKPACK-0331.01.100000412708.03120731" ItemDescription="EYESHADOW" Quantity="320" QuantityUOM="EA" UnitPrice="16.8" Amount1="5376" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0331" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="16.8" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="EYESHADOW#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17733" ItemType="LINE" LineId="" OrderSequence="9" Key1="PICKPACK-0332.01.100000412708.03120731" ItemDescription="SUEDE BLUSH" Quantity="288" QuantityUOM="EA" UnitPrice="14.4" Amount1="4147.2" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0332" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="14.4" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="SUEDE BLUSH#xA;HTS #:3304.91.0010#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17734" ItemType="LINE" LineId="" OrderSequence="10" Key1="PICKPACK-0333.01.100000412708.03120731" ItemDescription="EYESHADOW" Quantity="480" QuantityUOM="EA" UnitPrice="16.8" Amount1="8064" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0333" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="16.8" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="EYESHADOW#xA;HTS #:3304.20.0000#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
<InvoiceLine InvoiceLineId="17735" ItemType="LINE" LineId="" OrderSequence="11" Key1="PICKPACK-0335.01.100000412708.03120731" ItemDescription="BRONZING POWDER" Quantity="160" QuantityUOM="EA" UnitPrice="19.2" Amount1="3072" Amount2="" Amount3="" FactoryId="" AdjustedSacLineAmount="" TariffCode="" Attribute1="0335" Attribute2="01" Attribute3="100000412708" Attribute4="03120731" Attribute6="N" Attribute7="RT" Attribute8="CA" Attribute9="RT" Attribute11="12502" Attribute12="19.2" Attribute13="03120731" Attribute14="100000412708" Attribute15="100000412708" Attribute20="PICKPACK" Notes1="BRONZING POWDER#xA;HTS #:3304.91.0050#xA;ORIGIN:CANADA#xA;%TTL FOB:100.00" />
</InvoiceLineSet>
</InvoiceDetail>
</Invoice>