[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: RE: Transform does not work using a check on varia

Subject: RE: RE: Transform does not work using a check on variable
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sat, 15 Jul 2006 06:21:59 +0100
check if transform working
> I am unable to figure out what is wrong with the following  XSLT.

The error message seems fairly explicit:

Error on line 31 column 9 of file:/c:/temp/test.xsl:
  SXXP0003: Error reported by XML parser: The element type "Packs" must be
terminated by the
  matching end-tag "</Packs>".

You're doing this:

      <xsl:if test="$blindLots1='0'">
      <Packs/>
      <xsl:variable name="blindLots1">1</xsl:variable>
      </xsl:if>   

and later this:

     <xsl:if test="$blindLots1=' 1 '">
      </Packs>     
      <xsl:variable name="blindLots2">1</xsl:variable>
      </xsl:if>  

which suggests that you're under the impression that you can write a start
tag and an end tag as two separate operations. You can't, for two reasons:
firstly an XSLT stylesheet must be a well-formed XML document. More
fundamentally, XSLT is a language that transforms trees into trees: in a
tree, an element node is a single indivisible object: you can't write half a
node to a tree.

You also seem to be confused about the nature of XSLT variables. You've got
two variables called blindlots1, which often indicates that you are thinking
of variables in terms of non-functional languages that permit assignment;
and you've got a variable called blindLots2 which is never referenced and
can never be referenced.

I imagine that you're trying to achieve some kind of grouping. Go to
http://www.jenitennison.com/xslt/grouping to see how it should be done.

Michael Kay
http://www.saxonica.com/

> 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>

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.