Project

Profile

Help

Need xslt help

Added by Anonymous almost 15 years ago

Legacy ID: #7794419 Legacy Poster: tech za (techza)

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 and From the i want last 3 rows of data. But not from the first module , I want the data from second section of example : (63,3,PASS) and (62,3,PASS) @@@@@@@@@@---these are located in property/data see below-Last2 sections in --@@@@@@@@@@@@@@ I want these 3 values to be picked up and show in my output xml for parameters. Example output : m 63 728 ul 3 137 in PASS 1526 SQ 62 728 MT 3 137 LT FAIL 1526 You can see in above example If I am taking the Units from my 2nd section of xml and I want to take the <> from 1st section of input xml and <> as you can see I hardcoded it in xslt. Can anybody help me out with this @@@@@@@@@@@@@@----My XML File : @@@@@@@@@@@@@@@@ LNumber: Date: Reading Disk Thickness A1 09/03/2009 63 3 PASS A0 09/03/2009 62 3 FAIL LNumber: A1 Date 09/03/2009 Property Units Results Reading m Disk ul Thickness in Lnumber A0 Date 09/03/2009 Test Property Units Results Reading SQ Disk MT Thicknessk LT @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ XSLT File : ----------@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ <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 006173082 <certificate="Single"> MA 1519-8 A_A1 A1 m 1 728 ul 68 137 in 2 1526 m 1 728 ul 68 137 in 2 1526


Replies (1)

RE: Need xslt help - Added by Anonymous almost 15 years ago

Legacy ID: #7794551 Legacy Poster: Michael Kay (mhkay)

Sorry, but this forum is for help with problems with the Saxon product, it is not a place for XSLT programming advice. You have already asked the same question on the p2p.wrox.com forum. I usually recommend the xsl-list at mulberrytech - but you will have to work on making the question more understandable if you want a clear answer.

    (1-1/1)

    Please register to reply