sum if xsl

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
okay let me first say i am new to xslt.
Here is what the printout pdf looks like. it needs to change. my requirements are below the code blocks
http://i.imgur.com/NLIHCS7.jpg
here is the xml file it is pulling from<?xml version="1.0" encoding="UTF-8"?>
<RadanNestResults xmlns="http://www.radan.com/ns/nestresults
<NestRun>
<Program>
<ProgDetails>
<Time>2013-01-30T11:08:22-06:00</Time>
<Drawing>P4 24gaga72</Drawing>
<DrawingFile>C:UsersuserDesktopkathyreportkathyreportnestsP4 24gaga72.drg</DrawingFile>
<Material>GALV</Material>
<Thickness>0.036</Thickness>
<ThickUnits>in</ThickUnits>
<SheetX>120.000</SheetX>
<SheetY>48.000</SheetY>
<SheetUnits>in</SheetUnits>
<Machine>Motorum 2548</Machine>
<NumNozzles>1</NumNozzles>
<NumNozzlesPerSheet>1</NumNozzlesPerSheet>
</ProgDetails>
<UsedParts>
<UsedPart>
<Symbol>C:UsersuserDesktopkathyreport6X6 STOCK FOR FAN STAN.sym</Symbol>
<AnnotationItem>1</AnnotationItem>
<PerSheet>1</PerSheet>
<Total>1</Total>
<Bin>0</Bin>
</UsedPart>
</UsedParts>
<ProgResults>
<NumSheets>1</NumSheets>
<Utilisation>0.31</Utilisation>
<StdToolId>0</StdToolId>
</ProgResults>
</Program>
<Program>
<ProgDetails>
<Time>2013-01-30T11:10:05-06:00</Time>
<Drawing>P5 24gaga72</Drawing>
<DrawingFile>C:UsersuserDesktopkathyreportkathyreportnestsP5 24gaga72.drg</DrawingFile>
<Material>Mild Steel</Material>
<Thickness>0.135</Thickness>
<ThickUnits>in</ThickUnits>
<SheetX>96.001</SheetX>
<SheetY>48.000</SheetY>
<SheetUnits>in</SheetUnits>
<Machine>Motorum 2548</Machine>
<NumNozzles>1</NumNozzles>
<NumNozzlesPerSheet>1</NumNozzlesPerSheet>
</ProgDetails>
<UsedParts>
<UsedPart>
<Symbol>C:UsersuserDesktopkathyreport10GA MS ANGLE CLIP.sym</Symbol>
<AnnotationItem>1</AnnotationItem>
<PerSheet>1</PerSheet>
<Total>1</Total>
<Bin>0</Bin>
</UsedPart>
</UsedParts>
<ProgResults>
<NumSheets>1</NumSheets>
<Utilisation>0.28</Utilisation>
<StdToolId>0</StdToolId>
</ProgResults>
</Program>
<Program>
<ProgDetails>
<Time>2013-01-30T11:13:05-06:00</Time>
<Drawing>P6 24gaga72</Drawing>
<DrawingFile>C:UsersuserDesktopkathyreportkathyreportnestsP6 24gaga72.drg</DrawingFile>
<Material>GALV</Material>
<Thickness>0.105</Thickness>
<ThickUnits>in</ThickUnits>
<SheetX>120.000</SheetX>
<SheetY>48.000</SheetY>
<SheetUnits>in</SheetUnits>
<Machine>Motorum 2548</Machine>
<NumNozzles>1</NumNozzles>
<NumNozzlesPerSheet>1</NumNozzlesPerSheet>
</ProgDetails>
<UsedParts>
<UsedPart>
<Symbol>C:UsersuserDesktopkathyreportELE-MB-06ONLY 14 GALV STOCK.sym</Symbol>
<AnnotationItem>1</AnnotationItem>
<PerSheet>4</PerSheet>
<Total>4</Total>
<Bin>0</Bin>
</UsedPart>
</UsedParts>
<ProgResults>
<NumSheets>1</NumSheets>
<Utilisation>18.07</Utilisation>
<StdToolId>0</StdToolId>
</ProgResults>
</Program>
<NestRunTotals>
<OverallUtil numprogs="2 6.65</OverallUtil>
<UtilLastProg>18.07</UtilLastProg>
<NumPrograms>3</NumPrograms>
<NumSheets>3</NumSheets>
<NumRemnantsMade>0</NumRemnantsMade>
</NestRunTotals>
<Sheets>
<Sheet>
<Used>1</Used>
<Material>GALV</Material>
<Thickness>0.105</Thickness>
<ThickUnits>in</ThickUnits>
<SheetX>120.000</SheetX>
<SheetY>48.000</SheetY>
<SheetUnits>in</SheetUnits>
</Sheet>
<Sheet>
<Used>1</Used>
<Material>GALV</Material>
<Thickness>0.036</Thickness>
<ThickUnits>in</ThickUnits>
<SheetX>120.000</SheetX>
<SheetY>48.000</SheetY>
<SheetUnits>in</SheetUnits>
</Sheet>
<Sheet>
<Used>1</Used>
<Material>Mild Steel</Material>
<Thickness>0.135</Thickness>
<ThickUnits>in</ThickUnits>
<SheetX>96.001</SheetX>
<SheetY>48.000</SheetY>
<SheetUnits>in</SheetUnits>
</Sheet>
</Sheets>
</NestRun>
</RadanNestResults>

and here is the xsl it uses<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format" version="1.0
<xsl:template match="/RadanProject
<xsl:variable name="ReportTitle Material Summary</xsl:variable>
<fo:root>
<fo:layout-master-set>
<fo:simple-page-master master-name="Letter Page" page-width="8.3in" page-height="11.7in
<fo:region-body region-name="xsl-region-body" margin="17.780mm"/>
<fo:region-before region-name="xsl-region-before" display-align="after" extent="17.780mm"/>
<fo:region-after region-name="xsl-region-after" extent="17.780mm"/>
<fo:region-start region-name="xsl-region-start" extent="17.780mm"/>
<fo:region-end region-name="xsl-region-end" extent="17.780mm"/>
</fo:simple-page-master>
</fo:layout-master-set>
<fo:page-sequence master-reference="Letter Page
<fo:static-content flow-name="xsl-region-before" font-size="12pt" font-family="Helvetica
<fo:block> </fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-after" font-size="12pt" font-family="Helvetica
<fo:block> </fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-start" font-size="12pt" font-family="Helvetica
<fo:block> </fo:block>
</fo:static-content>
<fo:static-content flow-name="xsl-region-end" font-size="12pt" font-family="Helvetica
<fo:block> </fo:block>
</fo:static-content>

<fo:flow flow-name="xsl-region-body" font-family="Helvetica" font-size="12pt
<xsl:call-template name="header"/>
<xsl:call-template name="details"/>

<xsl:call-template name="title
<xsl:with-param name="reportname" select="$ReportTitle"/>
</xsl:call-template>

<xsl:call-template name="maintable"/>

<xsl:if test="RemnantSheets/RemnantSheet
<xsl:call-template name="remnantsusedtable"/>
</xsl:if>

<xsl:if test="Remnants/Remnant
<xsl:call-template name="remnantsmadetable"/>
</xsl:if>

</fo:flow>
</fo:page-sequence>
</fo:root>
</xsl:template>

<xsl:template name="remnantsmadetable

<xsl:call-template name="title
<xsl:with-param name="reportname Generated Remnants</xsl:with-param>
</xsl:call-template>
<fo:block>

<xsl:for-each select="GroupedByMaterialAndThickness/Material
<xsl:variable name="Mat_Of_Sheet <xsl:value-of select="@name"/></xsl:variable>
<xsl:for-each select="Thickness
<xsl:variable name="Thick_Of_Sheet <xsl:value-of select="@value"/></xsl:variable>
<xsl:variable name="Units_Of_Thick_Of_Sheet <xsl:value-of select="@units"/></xsl:variable>

<fo:block background-color="rgb(255,255,255)
<xsl:if test="Remnant
<fo:table table-layout="fixed" width="100%" border-collapse="collapse" display-align="center" text-align="center
<fo:table-column column-width="proportional-column-width(35)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(25)" column-number="2"/>
<fo:table-column column-width="proportional-column-width(25)" column-number="3"/>
<fo:table-column column-width="proportional-column-width(5)" column-number="4"/>
<fo:table-column column-width="proportional-column-width(10)" column-number="5"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt" number-columns-spanned="5" text-align="left
<fo:block font-weight="bold
<xsl:value-of select="$Mat_Of_Sheet"/>/<xsl:value-of select="$Thick_Of_Sheet"/><xsl:value-of select="$Units_Of_Thick_Of_Sheet"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block>Name</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block>Size</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block>Source</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block>Qty</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block>Area</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="Remnant
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block><xsl:value-of select="File_Name_Without_Extension"/></fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block><xsl:value-of select="format-number(RearrangedRadanAttributes/Attr124/@value, ###,##0.00)"/> x <xsl:value-of select="format-number(RearrangedRadanAttributes/Attr125/@value, ###,##0.00)"/> <xsl:value-of select="RearrangedRadanAttributes/Attr118/@value"/></fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block><xsl:value-of select="RearrangedRadanAttributes/Attr161/@value"/></fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block><xsl:value-of select="RearrangedRadanAttributes/Attr137/@value"/></fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block><xsl:value-of select="format-number(RearrangedRadanAttributes/Attr126/@value, ###,##0.00)"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</xsl:if>
</fo:block>
</xsl:for-each>
</xsl:for-each>
</fo:block>
</xsl:template>

<xsl:template name="remnantsusedtable
<xsl:call-template name="title
<xsl:with-param name="reportname Used Remnants</xsl:with-param>
</xsl:call-template>

<fo:block background-color="rgb(255,255,255)
<fo:table table-layout="fixed" width="100%" border-collapse="collapse" display-align="center" text-align="center
<fo:table-column column-width="proportional-column-width(95)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(5)" column-number="2"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block text-align="left Name</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block text-align="left Qty</fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="RemnantSheets/RemnantSheet
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block text-align="left <xsl:value-of select="FileName"/></fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt
<fo:block text-align="left <xsl:value-of select="Used"/></fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:for-each>
</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>

<xsl:template name="materialtable
<xsl:param name="material"/>

<xsl:for-each select="Thickness
<xsl:choose>
<xsl:when test="Sheet


<xsl:call-template name="thicknesstable
<xsl:with-param name="material" select="$material"/>
<xsl:with-param name="thickness" select="@value"/>
<xsl:with-param name="units" select="@units"/>
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:if test="Nest
<xsl:call-template name="thicknesstable
<xsl:with-param name="material" select="$material"/>
<xsl:with-param name="thickness" select="@value"/>
<xsl:with-param name="units" select="@units"/>
</xsl:call-template>
</xsl:if>
</xsl:otherwise>
</xsl:choose>
</xsl:for-each>
</xsl:template>

<xsl:template name="thicknesstable
<xsl:param name="material"/>
<xsl:param name="thickness"/>
<xsl:param name="units"/>

<fo:block background-color="rgb(255,255,255)
<fo:table table-layout="fixed" width="100%" border-collapse="collapse" text-align="left
<fo:table-column column-width="proportional-column-width(50)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(40)" column-number="2"/>
<fo:table-column column-width="proportional-column-width(10)" column-number="3"/>
<fo:table-header>
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt" number-columns-spanned="3" text-align="left
<fo:block font-weight="bold
<xsl:value-of select="$material"/>/<xsl:value-of select="$thickness"/><xsl:value-of select="$units"/>
</fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left Size</fo:block>
</fo:table-cell>

<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left P/N</fo:block>
</fo:table-cell>

<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<xsl:if test="$thickness != 0.135 and $thickness != 0.074 and $thickness != 0.105
<fo:block text-align="left LIN.IN.</fo:block>
</xsl:if>
<xsl:if test="$thickness = 0.135 or $thickness = 0.074 or $thickness = 0.105
<fo:block text-align="left Sheets</fo:block>
</xsl:if>
</fo:table-cell>
</fo:table-row>
</fo:table-header>
<fo:table-body>
<xsl:for-each select="Sheet
<xsl:if test="Used != 0
<fo:table-row>



<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left
<xsl:value-of select="SheetX"/>x<xsl:value-of select="SheetY"/><xsl:value-of select="SheetUnits"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left
<xsl:if test="$material = GALV <xsl:if test="$thickness = 0.036 and SheetY = 48 (ST-CL-G-20-48)</xsl:if><xsl:if test="$thickness = 0.036 and SheetY = 36 (ST-CL-G-20-36)</xsl:if><xsl:if test="$thickness = 0.036 and SheetY = 60 (ST-CL-G-20-60)</xsl:if><xsl:if test="$thickness = 0.048 and SheetY = 48 (ST-CL-G-18-48)</xsl:if><xsl:if test="$thickness = 0.048 and SheetY = 36 (ST-CL-G-18-36)</xsl:if><xsl:if test="$thickness = 0.048 and SheetY = 60 (ST-CL-G-18-60)</xsl:if><xsl:if test="$thickness = 0.074 and SheetX = 96.002 (ST-SH-G-14-48-96)</xsl:if><xsl:if test="$thickness = 0.074 and SheetX = 120.002 (ST-SH-G-14-48-120)</xsl:if><xsl:if test="$thickness = 0.074 and SheetY = 60 <xsl:if test="SheetX = 144 (ST-SH-G-14-60-144)</xsl:if></xsl:if><xsl:if test="$thickness = 0.074 and SheetX = 144.02 (ST-SH-G-14-48-144)</xsl:if><xsl:if test="$thickness = 0.135 and SheetX = 96.001 (ST-SH-G-10-48-96)</xsl:if><xsl:if test="$thickness = 0.135 and SheetX = 120.005 (ST-SH-G-10-48-120)</xsl:if><xsl:if test="$thickness = 0.135 and SheetX = 144.005 (ST-SH-G-10-48-144)</xsl:if><xsl:if test="$thickness = 0.105 and SheetX = 120 (ST-SH-G-12-48-120)</xsl:if></xsl:if>
<xsl:if test="$material = Mild Steel <xsl:if test="$thickness = 0.074 and SheetX = 96.002 (ST-SH-MS-14-48-96)</xsl:if><xsl:if test="$thickness = 0.074 and SheetX = 120.002 (ST-SH-MS-14-48-120)</xsl:if><xsl:if test="$thickness = 0.074 and SheetX = 120 <xsl:if test="$thickness = 0.074 and SheetY = 60 (ST-SH-MS-14-60-120)</xsl:if></xsl:if><xsl:if test="$thickness = 0.074 and SheetX = 144.02 (ST-SH-MS-14-48-144)</xsl:if><xsl:if test="$thickness = 0.135 and SheetX = 96.001 (ST-SH-MS-10-48-96)</xsl:if><xsl:if test="$thickness = 0.135 and SheetX = 120.005 (ST-SH-MS-10-48-120)</xsl:if><xsl:if test="$thickness = 0.135 and SheetX = 144.005 (ST-SH-MS-10-48-144)</xsl:if></xsl:if>
<xsl:if test="$material = ALZD <xsl:if test="$thickness = 0.036 and SheetY = 48 (ST-CL-A-20-48)</xsl:if><xsl:if test="$thickness = 0.036 and SheetY = 39 (ST-CL-A-20-39)</xsl:if><xsl:if test="$thickness = 0.062 and SheetY = 48 (ST-CL-A-16-48)</xsl:if>
</xsl:if>
</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left
<xsl:if test="$thickness != 0.135 and $thickness != 0.074 and $thickness != 0.105
<!--<xsl:value-of select="round(SheetX * SheetY * .01344 * Used)"/>-->
<xsl:value-of select="SheetX * Used"/>
</xsl:if>

<xsl:if test="$thickness = 0.135 or $thickness = 0.074 or $thickness = 0.105
<xsl:value-of select="Used"/>
</xsl:if>
</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if>
</xsl:for-each>

<xsl:call-template name="unexpectedsheets"/>

<fo:table-row>
<fo:table-cell>
<fo:block text-align="left </fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block text-align="left </fo:block>
</fo:table-cell>
</fo:table-row>

</fo:table-body>
</fo:table>
</fo:block>
</xsl:template>













<xsl:template name="unexpectedsheets
<!-- Check if there are any unexpected sheets -->
<xsl:if test="Nest
<xsl:for-each select="Nest
<xsl:if test="SheetUsed <xsl:if test="not(SheetUsed/SheetsListItems) and not(SheetUsed/RemnantSource)
<fo:table-row>
<fo:table-cell color="red" border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left
<xsl:value-of select="SheetUsed/SheetX"/>x<xsl:value-of select="SheetUsed/SheetY"/><xsl:value-of select="SheetUsed/SheetUnits"/>
</fo:block>
</fo:table-cell>
<fo:table-cell border="1pt solid black" padding="2pt" display-align="center" text-align="center
<fo:block text-align="left
<xsl:if test="SheetUsed/Thickness = 0.135 or SheetUsed/Thickness = 0.074 or SheetUsed/Thickness = 0.105
<xsl:value-of select="SheetUsed/Used"/>
</xsl:if>

<!--<xsl:value-of select="SheetUsed/Used"/>-->
<!--<xsl:value-of select="SheetX * Used"/>-->
<xsl:if test="SheetUsed/Thickness = 0.048 or SheetUsed/Thickness = 0.036
<xsl:value-of select="SheetUsed/Used * SheetUsed/SheetX"/>

</xsl:if>

</fo:block>
</fo:table-cell>
</fo:table-row>
</xsl:if></xsl:if>
</xsl:for-each>
</xsl:if>
</xsl:template>

<xsl:template name="maintable
<fo:block>
<xsl:for-each select="GroupedByMaterialAndThickness/Material
<xsl:call-template name="materialtable
<xsl:with-param name="material" select="@name"/>
</xsl:call-template>
</xsl:for-each>
</fo:block>
</xsl:template>

<xsl:template name="header
<fo:block>
<fo:external-graphic src="Company Logo.png" content-width="82.788mm" scaling="uniform" content-height="21.424mm" />
<fo:block-container z-index="1" position="absolute" left="85.910mm" top="5.237mm" width="94.162mm" height="12.167mm" overflow="hidden
<fo:block font-size="28pt" font-weight="bold" text-align="center" color="rgb(45,121,180) Nest Project Report</fo:block>
</fo:block-container>
</fo:block>
</xsl:template>

<xsl:template name="details
<fo:table table-layout="fixed" width = "100%
<fo:table-column column-width="proportional-column-width(20)" column-number="1"/>
<fo:table-column column-width="proportional-column-width(100)" column-number="2"/>

<fo:table-body>
<fo:table-row>
<fo:table-cell>
<fo:block color="rgb(45,121,180)" font-weight="bold Project name:</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="ProjectName"/></fo:block>
</fo:table-cell>
</fo:table-row>
<fo:table-row>
<fo:table-cell>
<fo:block color="rgb(45,121,180)" font-weight="bold User name:</fo:block>
</fo:table-cell>
<fo:table-cell>
<fo:block><xsl:value-of select="UserName/text()"/></fo:block>
</fo:table-cell>
</fo:table-row>
</fo:table-body>
</fo:table>
</xsl:template>

<xsl:template name="title
<xsl:param name="reportname"/>
<fo:block> </fo:block>
<fo:block color="rgb(255,255,255)" font-weight="bold" font-size="18pt" background-color="rgb(45,121,180)" >
<xsl:value-of select="$reportname"/>
</fo:block>
<fo:block> </fo:block>
</xsl:template>
</xsl:stylesheet><!-- ========================= END OF STYLESHEET ========================= -->

ive done some editing to the default sheet.
if you look at the pdf i need to do two things. If the part number is the same, i need to sum those columns and solely have those columns. so if there are two lines of the same partnumber, those lines need to be removed and have just the partnumber and the sum of the two similar lines.and i will save the second part for later.

View the full article
 
Back
Top