jderting
asked on
XSLT How to Count number of records in a 'table'
Hi all,
I set up an XSLT Report that divides up a list of files by extension. (the data you are looking at is info about files that failed running through a processing tool we have)
I am still new at this so I cheated and made an 'extension' field until I can figure that out.
Whatever the case, in the following XSLT, I have a list of files divided by extension, and a Total at the bottom (in this case, 5 files)
However, I am not sure how to subtotal on my divisions. (in this case, there should be 2 subtotals: (pdf) 1 File, and (doc) 4 files) I also need to subtotal the filebytes.
and, just so I dont have to do it again in the future, anyone know how to do my divisions without using my 'extension'(InputExt) field?
this sounds like it is easy to do, I'm just drawing a blank, can't seem to find an example online, and its kinda urgent, so I bumped up the points.
Since I am still learning, any comments about the format are welcome. (be nice :)
-K
first is the XML, followed by the XSLT
<?xml version='1.0'?>
<?xml-stylesheet type='text/xsl' href='File Exceptions Summary_StyleSheet.xsl'?>
<ExceptionsLog>
<tblProcessExceptions>
<DocID>1</DocID>
<InputFile>C:\x\Files\x.pd f</InputFi le>
<OutputFile>C:\x\Out\sadff ds\aoeui23 324\OCR\y. txt</Outpu tFile>
<FileBytes>3686</FileBytes >
<FileVerified>false</FileV erified>
<ErrorText>$E 0010 Unable to index PDF file. Damaged or corrupt PDF file.
Additional information: "bad xref"
getXRef -- bad xref line at 3286
</ErrorText>
<TimeStamp>22:17:27.116 4/30/2006</TimeStamp>
<InputExt>.pdf</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>2</DocID>
<InputFile>C:\x\Files\aaa. doc</Input File>
<OutputFile>C:\x\Out\sadff ds\aoeui23 324\OCR\eo eo.txt</Ou tputFile>
<FileBytes>448512</FileByt es>
<FileVerified>false</FileV erified>
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid style data)</ErrorText>
<TimeStamp>22:17:34.326 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>3</DocID>
<InputFile>C:\x\Files\iuue .doc</Inpu tFile>
<OutputFile>C:\x\Out\sadff ds\aoeui23 324\OCR\sd afddd2.txt </OutputFi le>
<FileBytes>913408</FileByt es>
<FileVerified>false</FileV erified>
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid style data)</ErrorText>
<TimeStamp>22:17:34.466 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>4</DocID>
<InputFile>C:\x\Files\0043 49\1\uuhhh .doc</Inpu tFile>
<OutputFile>C:\x\Out\sadff ds\aoeui23 324\OCR\sd afddd3.txt </OutputFi le>
<FileBytes>579584</FileByt es>
<FileVerified>false</FileV erified>
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid cbUPX in style)</ErrorText>
<TimeStamp>22:17:34.617 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>5</DocID>
<InputFile>C:\x\Files\0043 51\1\ydhtt n.doc</Inp utFile>
<OutputFile>C:\x\Out\sadff ds\aoeui23 324\OCR\sd afddd4.txt </OutputFi le>
<FileBytes>579584</FileByt es>
<FileVerified>false</FileV erified>
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid cbUPX in style)</ErrorText>
<TimeStamp>22:17:34.747 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblSectionInfo>
<ProjectName>Fred</Project Name>
<SectionName>SectionName</ SectionNam e>
</tblSectionInfo>
</ExceptionsLog>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:key name="extension" match="tblProcessException s" use="InputExt"/>
<xsl:template match="/">
<xsl:apply-templates select='tblProcessExceptio ns'/>
<HTML>
<TITLE>File Exceptions Summary</TITLE>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:10pt; background-color:#EEEEEE">
<DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt">
<br></br>
<table class="Project/Section ID">
<tr>
<td>
<FONT SIZE="2">
Project: <b>
<xsl:value-of select="//tblSectionInfo/P rojectName "/>
</b>
</FONT>
</td>
</tr>
<tr>
<td>
<FONT SIZE="2">
Section: <b>
<xsl:value-of select="//tblSectionInfo/S ectionName "/>
</b>
</FONT>
</td>
</tr>
</table>
<hr></hr>
<table class="List of Files">
<!-- Selectively populate Group Headings-->
<xsl:for-each select="//tblProcessExcept ions[count (. | key('extension',InputExt)[ 1]) = 1]">
<xsl:variable name="extension" select="InputExt" />
<tr class= "Report Fields">
<td class="extension">
<xsl:value-of select="$extension" />  
</td>
</tr>
<!-- Selectively populate fields-->
<xsl:for-each select="//tblProcessExcept ions">
<xsl:variable name="fieldEXT" select="InputExt" />
<xsl:if test="$fieldEXT=$extension ">
<tr>
<td class="InputFileName">
<FONT SIZE="2">
<xsl:value-of select="InputFile"/>
</FONT>
</td>
<td class="FileSize">
<xsl:value-of select="FileBytes" /> Bytes
</td>
</tr>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</table>
<hr></hr>
<table class="Grand Totals">
<td class="spacing">
    &# 160;    0; &# 160;    0; &# 160;    0; &# 160;    0; &# 160;    0; &# 160;    0; &# 160;    0;
</td>
<tr class="Summary">
<td class="File Count">
<FONT SIZE="2">
Total: <b>
<xsl:value-of select="format-number(coun t(//FileBy tes), '###,###')"/> Files
</b>
</FONT>
</td>
<td Class="FileSize">
<FONT SIZE="2">
Total: <b>
<xsl:value-of select="format-number(sum( //FileByte s)div 1024, '###,###')"/> KB
</b>
</FONT>
</td>
</tr>
</table>
<br></br>
</DIV>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
I set up an XSLT Report that divides up a list of files by extension. (the data you are looking at is info about files that failed running through a processing tool we have)
I am still new at this so I cheated and made an 'extension' field until I can figure that out.
Whatever the case, in the following XSLT, I have a list of files divided by extension, and a Total at the bottom (in this case, 5 files)
However, I am not sure how to subtotal on my divisions. (in this case, there should be 2 subtotals: (pdf) 1 File, and (doc) 4 files) I also need to subtotal the filebytes.
and, just so I dont have to do it again in the future, anyone know how to do my divisions without using my 'extension'(InputExt) field?
this sounds like it is easy to do, I'm just drawing a blank, can't seem to find an example online, and its kinda urgent, so I bumped up the points.
Since I am still learning, any comments about the format are welcome. (be nice :)
-K
first is the XML, followed by the XSLT
<?xml version='1.0'?>
<?xml-stylesheet type='text/xsl' href='File Exceptions Summary_StyleSheet.xsl'?>
<ExceptionsLog>
<tblProcessExceptions>
<DocID>1</DocID>
<InputFile>C:\x\Files\x.pd
<OutputFile>C:\x\Out\sadff
<FileBytes>3686</FileBytes
<FileVerified>false</FileV
<ErrorText>$E 0010 Unable to index PDF file. Damaged or corrupt PDF file.
Additional information: "bad xref"
getXRef -- bad xref line at 3286
</ErrorText>
<TimeStamp>22:17:27.116 4/30/2006</TimeStamp>
<InputExt>.pdf</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>2</DocID>
<InputFile>C:\x\Files\aaa.
<OutputFile>C:\x\Out\sadff
<FileBytes>448512</FileByt
<FileVerified>false</FileV
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid style data)</ErrorText>
<TimeStamp>22:17:34.326 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>3</DocID>
<InputFile>C:\x\Files\iuue
<OutputFile>C:\x\Out\sadff
<FileBytes>913408</FileByt
<FileVerified>false</FileV
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid style data)</ErrorText>
<TimeStamp>22:17:34.466 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>4</DocID>
<InputFile>C:\x\Files\0043
<OutputFile>C:\x\Out\sadff
<FileBytes>579584</FileByt
<FileVerified>false</FileV
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid cbUPX in style)</ErrorText>
<TimeStamp>22:17:34.617 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblProcessExceptions>
<DocID>5</DocID>
<InputFile>C:\x\Files\0043
<OutputFile>C:\x\Out\sadff
<FileBytes>579584</FileByt
<FileVerified>false</FileV
<ErrorText>$E 0010 Damaged or corrupt Word document (Invalid cbUPX in style)</ErrorText>
<TimeStamp>22:17:34.747 4/30/2006</TimeStamp>
<InputExt>.doc</InputExt>
</tblProcessExceptions>
<tblSectionInfo>
<ProjectName>Fred</Project
<SectionName>SectionName</
</tblSectionInfo>
</ExceptionsLog>
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="html"/>
<xsl:key name="extension" match="tblProcessException
<xsl:template match="/">
<xsl:apply-templates select='tblProcessExceptio
<HTML>
<TITLE>File Exceptions Summary</TITLE>
<BODY STYLE="font-family:Arial, helvetica, sans-serif; font-size:10pt; background-color:#EEEEEE">
<DIV STYLE="margin-left:20px; margin-bottom:1em; font-size:10pt">
<br></br>
<table class="Project/Section ID">
<tr>
<td>
<FONT SIZE="2">
Project: <b>
<xsl:value-of select="//tblSectionInfo/P
</b>
</FONT>
</td>
</tr>
<tr>
<td>
<FONT SIZE="2">
Section: <b>
<xsl:value-of select="//tblSectionInfo/S
</b>
</FONT>
</td>
</tr>
</table>
<hr></hr>
<table class="List of Files">
<!-- Selectively populate Group Headings-->
<xsl:for-each select="//tblProcessExcept
<xsl:variable name="extension" select="InputExt" />
<tr class= "Report Fields">
<td class="extension">
<xsl:value-of select="$extension" />  
</td>
</tr>
<!-- Selectively populate fields-->
<xsl:for-each select="//tblProcessExcept
<xsl:variable name="fieldEXT" select="InputExt" />
<xsl:if test="$fieldEXT=$extension
<tr>
<td class="InputFileName">
<FONT SIZE="2">
<xsl:value-of select="InputFile"/>
</FONT>
</td>
<td class="FileSize">
<xsl:value-of select="FileBytes" /> Bytes
</td>
</tr>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</table>
<hr></hr>
<table class="Grand Totals">
<td class="spacing">
    &#
</td>
<tr class="Summary">
<td class="File Count">
<FONT SIZE="2">
Total: <b>
<xsl:value-of select="format-number(coun
</b>
</FONT>
</td>
<td Class="FileSize">
<FONT SIZE="2">
Total: <b>
<xsl:value-of select="format-number(sum(
</b>
</FONT>
</td>
</tr>
</table>
<br></br>
</DIV>
</BODY>
</HTML>
</xsl:template>
</xsl:stylesheet>
ASKER
That's great! thank you :)
Please pardon my newbieness, but how would I count the FileBytes?
-K
Please pardon my newbieness, but how would I count the FileBytes?
-K
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
count(key('extension',Inpu
If the current goup is "pdf" then this looks like:
count(key('extension','pdf
which will return the count of records with "pdf" in the InputExt.
Regards,
Mike Sharp