[xsl] RE: Transform does not work using a check on variable

Subject: [xsl] RE: Transform does not work using a check on variable
From: "Goel Victor Rajan" <goel.rajan@xxxxxxxxxx>
Date: Sat, 15 Jul 2006 09:54:57 +0530
Hi all, 

I am unable to figure out what is wrong with the following  XSLT.
Thanks for any help.

XSL

<?xml version="1.0" encoding="ISO-8859-1"?> <xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform";>
  <xsl:template match="/">
<StudyData studyId="{CC/MessageBody/ProtocolCD}">
  <SupplyManagement messageType="Shipment Details">
    <ShipmentDetails id="">
      <LocationRef></LocationRef>
      <DestinationRef></DestinationRef>
      <ShipmentDate><xsl:value-of
select="CC/MessageHeader/CreationDateTime"/></ShipmentDate>      
      <Lots>
      <xsl:for-each select="CC/MessageBody/Materials/Material/Lots/Lot">
        <Lot>
          <LotNumber><xsl:value-of select="LotID"/></LotNumber>   
          <LotCountries>
          <xsl:for-each select="LotCountries/Country">
                <LotCountry><xsl:value-of
select="CountryCode"/></LotCountry>
          </xsl:for-each>               
          </LotCountries>
          <LotExpiryDate><xsl:value-of
select="LotRetestDate"/></LotExpiryDate>
        </Lot>
      </xsl:for-each>
      </Lots>
    <xsl:variable name="blindLots1">0</xsl:variable >
    <xsl:for-each select="CC/MessageBody/Materials/Material/Lots/Lot"> 
    <xsl:if test="current()/LotType='BLIND'" >     
      <xsl:if test="$blindLots1='0'">
      <Packs>
      <xsl:variable name="blindLots1">1</xsl:variable>
      </xsl:if>      
        <xsl:for-each select="Kits/Kit">
          <Pack replace="true">
            <PackRef><xsl:value-of select="KitRandomID"/></PackRef>
            <DrugData>
              <DrugType><xsl:value-of
select="../../../../MaterialID"/></DrugType>
              <DrugDesc><xsl:value-of
select="../../../../MaterialDescription"/></DrugDesc>
            </DrugData>
            <PackLotNumber><xsl:value-of
select="../../LotID"/></PackLotNumber>
          </Pack>
        </xsl:for-each>
    </xsl:if>
    </xsl:for-each> 
     <xsl:if test="$blindLots1=' 1 '">
      </Packs>     
      <xsl:variable name="blindLots2">1</xsl:variable>
      </xsl:if>      
    </ShipmentDetails>
  </SupplyManagement>
</StudyData>
</xsl:template>
</xsl:stylesheet>
 
XML to be transformed
 
<?xml version = '1.0' encoding = 'UTF-8' standalone = 'yes'?> <CC>
   <MessageHeader>
              <MessageID>7164</MessageID>
              <MessageName>Message to COMMON for Protocol TEST12APR.
Inventory change Lot Id 06-003344S</MessageName>
              <MessageVersion>1</MessageVersion>
              <CreationDateTime>2006-APR-17T15:04:04</CreationDateTime>
              <MessageType>Sent</MessageType>
              <CorrelationID>
              </CorrelationID>
              <EventID>39</EventID>
              <EventName>Inventory Adjustment on Miscellaneous
Shipments</EventName>
              <EventVersion>1</EventVersion>
              <SendingApplication>Clinicopia</SendingApplication>
              <ReceivingApplication>COMMON</ReceivingApplication>
   </MessageHeader>
   <MessageBody>
              <ProtocolCD>TEST12APR</ProtocolCD>
              <ProtocolName>
              </ProtocolName>
              <ProtocolType>BLIND</ProtocolType>
              <RandomizationType>KIT</RandomizationType>
              <ProtocolStatus>NEW</ProtocolStatus>
              <Materials>
                         <Material>
                                    <MaterialID>AKT4 PB5-IN</MaterialID>
                                    <MaterialVersion>1</MaterialVersion>
                                    <MaterialDescription>AKT4
PB5</MaterialDescription>
                                    <MaterialType>PACKAGED
MATERIAL</MaterialType>
                                    <MaterialSubtype>PACKAGED
BOX</MaterialSubtype>
 
<MaterialDosageCode>D1</MaterialDosageCode>
                                    <MaterialUoM>Unit</MaterialUoM>
                                    <ControlSubstance>
                                    </ControlSubstance>
                                    <Vendors>
                                       <Vendor>
                                                  <VendorCode>
                                                  </VendorCode>
                                                  <VendorMaterialID>
                                                  </VendorMaterialID>
                                       </Vendor>
                                    </Vendors>
                                    <Lots>
                                       <Lot>
                                                  <LotID>06-003344S</LotID>
                                                  <LotType>OPEN</LotType>
                                                  <VendorCode>
                                                  </VendorCode>
                                                  <VendorLotID>
                                                  </VendorLotID>
                                                  <LotCountries>
                                                             <Country>
 
<CountryCode>C1</CountryCode>
 
<CountryName>CN1</CountryName>
                                                             </Country>
                                                  </LotCountries>
 
<LotWarehouseCD>ANIWARE</LotWarehouseCD>
 
<LotWarehouseDescription>ANIWARE DESC</LotWarehouseDescription>
 
<LotWarehouseType>WAREHOUSE</LotWarehouseType>
 
<LotQAStatus>RELEASED</LotQAStatus>
 
<LotManufactureDate>2006/04/12 00:00:00</LotManufactureDate>
                                                  <LotRetestDate>2007/04/21
00:00:00</LotRetestDate>
                                                  <LotStorageCondition>15-25
C</LotStorageCondition>
 
<LotTotalQuantity>4</LotTotalQuantity>
 
<LotTransactionQuantity>1</LotTransactionQuantity>
                                                  <Kits>
                                                             <Kit>
 
<KitRandomID>003</KitRandomID>
 
<KitNumber>
 
</KitNumber>
 
<KitVisitSequence>
 
</KitVisitSequence>
 
<KitQAStatus>RELEASED</KitQAStatus>
 
<KitRetestDate>2007/04/21 00:00:00</KitRetestDate>
 
<KitQuantity>1</KitQuantity>
                                                             </Kit>
                                                  </Kits>
                                       </Lot>
                                       <Lot>
                                                  <LotID>06-003344S</LotID>
                                                  <LotType>BLIND</LotType>
                                                  <VendorCode>
                                                  </VendorCode>
                                                  <VendorLotID>
                                                  </VendorLotID>
                                                  <LotCountries>
                                                             <Country>
 
<CountryCode>C3</CountryCode>
 
<CountryName>CN3</CountryName>
                                                             </Country>
                                                             <Country>
 
<CountryCode>C4</CountryCode>
 
<CountryName>CN4</CountryName>
                                                             </Country>
                                                  </LotCountries>
 
<LotWarehouseCD>ANIWARE</LotWarehouseCD>
 
<LotWarehouseDescription>ANIWARE DESC</LotWarehouseDescription>
 
<LotWarehouseType>WAREHOUSE</LotWarehouseType>
 
<LotQAStatus>RELEASED</LotQAStatus>
 
<LotManufactureDate>2006/04/12 00:00:00</LotManufactureDate>
                                                  <LotRetestDate>2007/04/21
00:00:00</LotRetestDate>
                                                  <LotStorageCondition>15-25
C</LotStorageCondition>
 
<LotTotalQuantity>8</LotTotalQuantity>
 
<LotTransactionQuantity>1</LotTransactionQuantity>
                                                  <Kits>
                                                             <Kit>
 
<KitRandomID>2007/04/21 00:00:00</KitRandomID>
 
<KitNumber>1</KitNumber>
 
<KitVisitSequence>003</KitVisitSequence>
 
<KitQAStatus>
 
</KitQAStatus>
 
<KitRetestDate>
 
</KitRetestDate>
 
<KitQuantity>RELEASED</KitQuantity>
                                                             </Kit>
                                                             <Kit>
 
<KitRandomID>017</KitRandomID>
 
<KitNumber>
 
</KitNumber>
 
<KitVisitSequence>
 
</KitVisitSequence>
 
<KitQAStatus>RELEASED</KitQAStatus>
 
<KitRetestDate>2007/04/21 00:00:00</KitRetestDate>
 
<KitQuantity>1</KitQuantity>
                                                             </Kit>
                                                  </Kits>
                                       </Lot>
                                    </Lots>
                         </Material>
                         <Material>
                                    <MaterialID>AKT4 PB5-IO</MaterialID>
                                    <MaterialVersion>1</MaterialVersion>
                                    <MaterialDescription>AKT4
PB5</MaterialDescription>
                                    <MaterialType>PACKAGED
MATERIAL</MaterialType>
                                    <MaterialSubtype>PACKAGED
BOX</MaterialSubtype>
 
<MaterialDosageCode>D1</MaterialDosageCode>
                                    <MaterialUoM>Unit</MaterialUoM>
                                    <ControlSubstance>
                                    </ControlSubstance>
                                    <Vendors>
                                       <Vendor>
                                                  <VendorCode>
                                                  </VendorCode>
                                                  <VendorMaterialID>
                                                  </VendorMaterialID>
                                       </Vendor>
                                    </Vendors>
                                    <Lots>
                                       <Lot>
                                                  <LotID>06-003352S</LotID>
                                                  <LotType>BLIND</LotType>
                                                  <VendorCode>
                                                  </VendorCode>
                                                  <VendorLotID>
                                                  </VendorLotID>
                                                  <LotCountries>
                                                             <Country>
 
<CountryCode>C5</CountryCode>
 
<CountryName>CN5</CountryName>
                                                             </Country>
                                                             <Country>
 
<CountryCode>C6</CountryCode>
 
<CountryName>CN6</CountryName>
                                                             </Country>
                                                  </LotCountries>
 
<LotWarehouseCD>ANIWARE</LotWarehouseCD>
 
<LotWarehouseDescription>ANIWARE DESC</LotWarehouseDescription>
 
<LotWarehouseType>WAREHOUSE</LotWarehouseType>
 
<LotQAStatus>RELEASED</LotQAStatus>
 
<LotManufactureDate>2006/04/17 00:00:00</LotManufactureDate>
                                                  <LotRetestDate>2007/05/04
00:00:00</LotRetestDate>
                                                  <LotStorageCondition>15-25
C</LotStorageCondition>
 
<LotTotalQuantity>8</LotTotalQuantity>
 
<LotTransactionQuantity>1</LotTransactionQuantity>
                                                  <Kits>
                                                             <Kit>
 
<KitRandomID>004</KitRandomID>
 
<KitNumber>
 
</KitNumber>
 
<KitVisitSequence>
 
</KitVisitSequence>
 
<KitQAStatus>RELEASED</KitQAStatus>
 
<KitRetestDate>2007/05/04 00:00:00</KitRetestDate>
 
<KitQuantity>1</KitQuantity>
                                                             </Kit>
                                       </Lot>
                                    </Lots>
                         </Material>
              </Materials>
   </MessageBody>
</CC>
 

Thanks and Regards

Goel 

Current Thread