Hi,

I need some help in xslt. I am trying to develop a xslt , I have pasted the 
short format of all 3 files below, The Input xml file. The xslt and output xml.
I will be very great full If anybody can help. I have tried everything but no 
luck. I am using @@@@ for comment or to explain in below files.


If you see my xml file I have 2 section in the xml <Partcase1> and <Testlot>


>From the <Case1row> i want last 3 rows of data. But not from the first module 
>, I want the data from second section of <Case1row>
example : (63,3,PASS) and (62,3,PASS) @@@@@@@@@@---these are located in 
property/data see below-Last2 sections in <case1row>--@@@@@@@@@@@@@@

I want these 3 values to be picked up and show in my output xml for parameters.

Example output : 

               <Parameters>
                  <Parameter>                    
                     <unit>m</unit>  
                     <Value>63</Value>
                     <code>728</code>
                  </Parameter>
                  <Parameter>                     
                     <unit>ul</unit>                
                     <Value>3</Value>                    
                     <code>137</code>
                  </Parameter>
                  <Parameter>                                        
                     <unit>in</unit>     
                     <Value>PASS</Value>                    
                     <code>1526</code>
                  </Parameter>
               </Parameters>
               <Parameters>
                  <Parameter>                    
                     <unit>SQ</unit>  
                     <measurementValue>62</measurementValue>
                     <code>728</code>
                  </Parameter>
                  <Parameter>                     
                     <unit>MT</unit>                
                     <Value>3</Value>                    
                     <code>137</code>
                  </Parameter>
                  <Parameter>                                        
                     <unit>LT</unit>     
                     <Value>FAIL</Value>                    
                     <code>1526</code>
                  </Parameter>
               </Parameters>



You can see in above example If I am taking the Units from my 2nd section of 
xml <testlot> 
and I want to take the <<value>> from 1st section of input xml <Case1row> and 
<<Code>> as you can see I hardcoded it in xslt.

Can anybody help me out with this


@@@@@@@@@@@@@@----My XML File : @@@@@@@@@@@@@@@@

<xml>
 <parent>
  <certificate>
   <content>
    <block >            
     <partcase1>        
      <case1>          
         <case1data>
          <case1row >
                <property><data> LNumber: </data></property>
                <property><data> Date: </data></property>
                <property><data>Reading</data></property>
                <property><data>Disk</data></property>
                <property><data>Thickness</data></property>
          </case1row >
          <case1row >
                <property><data> A1 </data></property>
                <property><data> 09/03/2009 </data></property>
                <property><data>63</data></property>
                <property><data>3</data></property>
                <property><data>PASS</data></property>
          </case1row >
                <case1row >
                <property><data> A0 </data></property>
                <property><data> 09/03/2009 </data></property>
                <property><data>62</data></property>
                <property><data>3</data></property>
                <property><data>FAIL</data></property>
         </case1row >    
        </case1data>                    
       </case1>         
      </partcase1>              
     </block>
     <testlot>
        <lnumber>
         <label>LNumber:</label>
         <value>A1</value>
         <datelabel>Date</datelabel>
         <date>09/03/2009</date>
        </lnumber>
        <aggheader>
         <name>Property</name>  
         <units>Units</units>
         <results>Results</results>             
        </aggheader>
        <aggdata>
         <namevalue>Reading</namevalue>  
         <units>m</units>               
        </aggdata>
        <aggdata>
         <namevalue>Disk</namevalue>    
         <units>ul</units>              
        </aggdata>
        <aggdata>
         <namevalue>Thickness</namevalue>        
         <units>in</units>              
        </aggdata>
     </testlot>
     <testlot>
        <lnumber>
         <label>Lnumber</label>
         <value>A0</value>
         <datelabel>Date</datelabel>
         <date>09/03/2009</date>
        </lnumber>
        <aggheader>
         <name>Test Property</name>     
         <units>Units</units>
         <results>Results</results>             
        </aggheader>
        <aggdata>
         <namevalue>Reading</namevalue>  
         <units>SQ</units>              
        </aggdata>
        <aggdata>
         <namevalue>Disk</namevalue>    
         <units>MT</units>              
        </aggdata>
        <aggdata>
        <namevalue>Thicknessk</namevalue>        
         <units>LT</units>              
        </aggdata>
    </testlot>
   </content>
  </certificate>
 </parent>
</xml>

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ XSLT File : 
----------@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; version="1.0">
    <xsl:output method="xml" encoding="utf-8" omit-xml-declaration="no" 
indent="yes" />    
    <xsl:template match="/">
        <xsl:element name="File" 
namespace="x-schema:../Schema/QualityCertificateSchema2001Jul.xml">    
            <xsl:element name="Sites" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">
                <xsl:element name="Description" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">           
                    <xsl:element name="Certificates" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">
                        <xsl:for-each select="//testlot">
                            <xsl:variable name="LotNode" select="." />
                            <xsl:variable name="Lot" select="./lotnumber/value" 
/>                       
                            <xsl:element name="Certificate" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">
                                <xsl:element name="Parameters" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">
                                    <xsl:for-each 
select="$LotNode/aggregatedresultsdata">
                                        <xsl:variable name="PropertyNode" 
select="." />
                                        <xsl:variable name="PropertyName" 
select="$PropertyNode/namevalue" />
                                        <xsl:element name="Parameter" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml"> 
                                            <xsl:element name="unit" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">                    
                           
                                                  <xsl:value-of select="units" 
/>      
                                            </xsl:element>
                                            <xsl:element 
name="measurementValue" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">
                                                <xsl:variable name="aggdisp" 
select="//testlot/@aggrDisp"/>                                                
                                                <xsl:variable name="data1" 
select="//partcase1/case1/case1data/case1row"/>
                                                <xsl:variable name="data2" 
select="//partcase2/case1/case1data/case1row"/>
                                                <xsl:variable name="data3" 
select="//partcase3/case1/case1data/case1row"/>
                                                <xsl:variable name="data4" 
select="//partcase4/case1/case1data/case1row"/>
                                                <xsl:variable name="Code1" 
select="$PropertyNode/namevalue" />
                                                <xsl:variable name="datalot1" 
select="$data1/property/data[. mod 2=1][1]"/>
                                                <xsl:variable name="datalot2" 
select="$data2/property/data[. mod 3=2][1]"/>
                                                <xsl:variable name="datalot3" 
select="$data3/property/data[. mod 4=2][1]"/>
                                                <xsl:choose>                    
                                
                                                    <xsl:when 
test="$Code1='Reading'"><xsl:value-of select="$datalot1"/></xsl:when> 
                                                    <xsl:when 
test="$Code1='Disk'"><xsl:value-of select="$datalot2"/></xsl:when>
                                                    <xsl:when 
test="$Code1='Thickness'"><xsl:value-of select="$datalot3"/></xsl:when>         
                                           
                                                    <xsl:otherwise>
                                                        <xsl:value-of 
select="$Code1" />
                                                    </xsl:otherwise>
                                                </xsl:choose>   
                                            </xsl:element> 
                                            <xsl:element name="code" 
namespace="x-schema:../Schema/Certificateschema2001Jul.xml">
                                                <xsl:variable name="code_agg" 
select="$PropertyNode/namevalue" />                                             
   
                                                <xsl:choose>
                                                    <xsl:when 
test="$code_agg='Property'">test</xsl:when>
                                                    <xsl:when 
test="$code_agg='Flatness'">728</xsl:when>
                                                    <xsl:when 
test="$code_agg='Disk'">137</xsl:when>
                                                    <xsl:when 
test="$code_agg='Thickness'">1526</xsl:when>                                    
               
                                                    <xsl:otherwise>             
                                           
                                                    </xsl:otherwise>
                                                </xsl:choose>
                                            </xsl:element>                      
            
                                        </xsl:element>                          
                                                     
                                    </xsl:for-each>                             
                                                                         
                                </xsl:element>                                 
                                </xsl:element>                        
                        </xsl:for-each>
                   </xsl:element>                    
                </xsl:element>
            </xsl:element>
        </xsl:element>
    </xsl:template>    
</xsl:stylesheet>


@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ ---Output 
file----@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
I am looking for the output like this

<?xml version="1.0" encoding="utf-8"?>
<File xmlns="x-schema:../Schema/QualityCertificateSchema2001Jul.xml">   
   <Sites>
      <Description>
         <manufacturerNumber>006173082</manufacturerNumber>         
         <Certificates>
            <certificate="Single">  
               <Description>
                  <pName>MA</pName>
                  <Part>1519-8</Part>
                  <Order>A_A1</Order>   
                  <lNumber>A1</lNumber>
               </Description>  
               <Parameters>
                  <Parameter>                    
                     <unit>m</unit>  
                     <measurementValue>1</measurementValue>
                     <code>728</code>
                  </Parameter>
                  <Parameter>                     
                     <unit>ul</unit>                
                     <Value>68</Value>                    
                     <code>137</code>
                  </Parameter>
                  <Parameter>                                        
                     <unit>in</unit>     
                     <Value>2</Value>                    
                     <code>1526</code>
                  </Parameter>
               </Parameters>
               <Parameters>
                  <Parameter>                    
                     <unit>m</unit>  
                     <measurementValue>1</measurementValue>
                     <code>728</code>
                  </Parameter>
                  <Parameter>                     
                     <unit>ul</unit>                
                     <Value>68</Value>                    
                     <code>137</code>
                  </Parameter>
                  <Parameter>                                        
                     <unit>in</unit>     
                     <Value>2</Value>                    
                     <code>1526</code>
                  </Parameter>
               </Parameters>
            </Certificate>           
         </Certificates>
      </Description>
   </Sites>
</File>
--
Posted by "techza" at Nuxeo Discussions <http://nuxeo.org/discussions>
View the complete thread: 
<http://www.nuxeo.org/discussions/thread.jspa?threadID=3079#9115>
_______________________________________________
ECM mailing list
[email protected]
http://lists.nuxeo.com/mailman/listinfo/ecm
To unsubscribe, go to http://lists.nuxeo.com/mailman/options/ecm

Reply via email to