Hi ALL,
As i am new to XSLT i am not able to implement the logic,
Please share your views if any know's how do this.
i have an xml
<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="Temp.xsl"?>
<Rowsets DateCreated="2011-02-14T12:24:00" EndDate="2011-02-14T12:24:00" StartDate="2011-02-14T11:24:00" Version="12.0.2 Build(88)">
<Rowset>
<Columns>
<Column Description="BatchNumber" MaxRange="1" MinRange="0" Name="BatchNumber" SQLDataType="12" SourceColumn="BatchNumber" />
<Column Description="VersionCode" MaxRange="1" MinRange="0" Name="VersionCode" SQLDataType="3" SourceColumn="VersionCode" />
<Column Description="MaterialType" MaxRange="1" MinRange="0" Name="MaterialType" SQLDataType="12" SourceColumn="MaterialType" />
<Column Description="LotNumber" MaxRange="1" MinRange="0" Name="LotNumber" SQLDataType="4" SourceColumn="LotNumber" />
<Column Description="RRComplete" MaxRange="1" MinRange="0" Name="RRComplete" SQLDataType="-6" SourceColumn="RRComplete" />
<Column Description="ReviewerName" MaxRange="1" MinRange="0" Name="ReviewerName" SQLDataType="12" SourceColumn="ReviewerName" />
<Column Description="ReviewStartDate" MaxRange="1" MinRange="0" Name="ReviewStartDate" SQLDataType="93" SourceColumn="ReviewStartDate" />
<Column Description="ReviewEndDate" MaxRange="1" MinRange="0" Name="ReviewEndDate" SQLDataType="93" SourceColumn="ReviewEndDate" />
<Column Description="ProjectedEndDate" MaxRange="1" MinRange="0" Name="ProjectedEndDate" SQLDataType="93" SourceColumn="ProjectedEndDate" />
<Column Description="DispositionerName" MaxRange="1" MinRange="0" Name="DispositionerName" SQLDataType="12" SourceColumn="DispositionerName" />
<Column Description="ReceiptDate" MaxRange="1" MinRange="0" Name="ReceiptDate" SQLDataType="93" SourceColumn="ReceiptDate" />
<Column Description="TargetDispositionDate" MaxRange="1" MinRange="0" Name="TargetDispositionDate" SQLDataType="93" SourceColumn="TargetDispositionDate" />
<Column Description="DRComplete" MaxRange="1" MinRange="0" Name="DRComplete" SQLDataType="-6" SourceColumn="DRComplete" />
<Column Description="DispositionedDate" MaxRange="1" MinRange="0" Name="DispositionedDate" SQLDataType="93" SourceColumn="DispositionedDate" />
<Column Description="RecommendedUsageDecision" MaxRange="1" MinRange="0" Name="RecommendedUsageDecision" SQLDataType="12" SourceColumn="RecommendedUsageDecision" />
<Column Description="FinalUsageDecision" MaxRange="1" MinRange="0" Name="FinalUsageDecision" SQLDataType="12" SourceColumn="FinalUsageDecision" />
<Column Description="BatchStatus" MaxRange="1" MinRange="0" Name="BatchStatus" SQLDataType="12" SourceColumn="BatchStatus" />
<Column Description="Plant" MaxRange="1" MinRange="0" Name="Plant" SQLDataType="12" SourceColumn="Plant" />
<Column Description="MaterialNumber" MaxRange="1" MinRange="0" Name="MaterialNumber" SQLDataType="12" SourceColumn="MaterialNumber" />
<Column Description="MaterialDescription" MaxRange="1" MinRange="0" Name="MaterialDescription" SQLDataType="-1" SourceColumn="MaterialDescription" />
<Column Description="DateOfManufacture" MaxRange="1" MinRange="0" Name="DateOfManufacture" SQLDataType="93" SourceColumn="DateOfManufacture" />
<Column Description="ExpiryDate" MaxRange="1" MinRange="0" Name="ExpiryDate" SQLDataType="93" SourceColumn="ExpiryDate" />
<Column Description="QuantityManufactured" MaxRange="1" MinRange="0" Name="QuantityManufactured" SQLDataType="12" SourceColumn="QuantityManufactured" />
<Column Description="BatchComments" MaxRange="1" MinRange="0" Name="BatchComments" SQLDataType="-1" SourceColumn="BatchComments" />
<Column Description="Stock" MaxRange="1" MinRange="0" Name="Stock" SQLDataType="-1" SourceColumn="Stock" />
</Columns>
<Row>
<BatchNumber>A12345</BatchNumber>
<VersionCode>1</VersionCode>
<MaterialType>Raw</MaterialType>
<LotNumber>12345</LotNumber>
<RRComplete>0</RRComplete>
<ReviewerName>Ankit</ReviewerName>
<ReviewStartDate>2011-02-08T00:00:00</ReviewStartDate>
<ReviewEndDate>2011-02-15T00:00:00</ReviewEndDate>
<ProjectedEndDate>TimeUnavailable</ProjectedEndDate>
<DispositionerName>Ankit</DispositionerName>
<ReceiptDate>2011-02-01T00:00:00</ReceiptDate>
<TargetDispositionDate>2011-06-11T00:00:00</TargetDispositionDate>
<DRComplete>0</DRComplete>
<DispositionedDate>TimeUnavailable</DispositionedDate>
<RecommendedUsageDecision>---</RecommendedUsageDecision>
<FinalUsageDecision>---</FinalUsageDecision>
<BatchStatus>---</BatchStatus>
<Plant>PR12</Plant>
<MaterialNumber>A00003434</MaterialNumber>
<MaterialDescription>No breaks</MaterialDescription>
<DateOfManufacture>2010-12-02T00:00:00</DateOfManufacture>
<ExpiryDate>1930-03-05T00:00:00</ExpiryDate>
<QuantityManufactured>69.3454LT</QuantityManufactured>
<BatchComments>---</BatchComments>
<Stock>Resticted</Stock>
</Row>
</Rowset>
</Rowsets>
I am attaching the followoing XSLT to generate a report using this XML data...
XSLT
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:java="http://xml.apache.org/xslt/java" exclude-result-prefixes="java">
<xsl:template match="/">
<xsl:apply-templates select="Rowsets/Rowset"/>
</xsl:template>
<xsl:template match="Rowsets/Rowset">
<html>
<head>
<title> In Process Batch Details </title>
<style>
*{
font: 8pt verdana;
}
body {
background-color:#F6F7FB;
display: block;
page: Report;
counter-reset: page 1
}
<!-- Sizing the page -->
@page { size: A4 portrait; }
<!-- Conter to show line number while printing -->
@page main {
@top { content: string(chapter-title) }
@bottom {
content: "Page " counter(page) " of " counter(pages)
}
}
chapter title { string-set: chapter-title content() }
table { empty-cells: show; border-spacing: 0px; margin: 0px; padding: 0px; align:center}
.pagebreak {page-break-after: always;}
.tableReportHeader{border-top: solid #4A6ACC 1px; border-left: solid #4A6ACC 1px; border-right: solid #4A6ACC 1px; width: 645px;}
.tabledetails{border-left: solid #4A6ACC 1px; border-right: solid #4A6ACC 1px; width: 645px; }
.tableReportFooter{bottom: 2px;border-bottom: solid #4A6ACC 1px; border-left: solid #4A6ACC 1px; border-right: solid #4A6ACC 1px; width: 645px;}
.imglogo{border-style: none; vertical-align: top; border-color: #F6F7FB;}
td{vertical-align: top; font-family: Arial, Helvetica, sans-serif; font-size: 9pt}
.tdmargin{width:10px;}
.documentheader{font-family:Arial; font-size:9pt; color:#4A6ACC; font-weight:bold;}
th{font-family:Arial; font-size:8pt; color:white; background-color: #4A6ACC; text-align:center;border: solid 1px darkblue;}
.tdorderHeader{border: solid 1px #4A6ACC;}
.blueline{border-bottom: solid #4A6ACC 1px;}
.documenttotal{font-family:Arial; font-size:9pt; color:#4A6ACC; font-weight:bold;border-bottom: solid #4A6ACC 1px;}
.tdtotalmargin{width:450px;}
</style>
</head>
<body>
<xsl:copy-of select="$ReportHeader"/> <!-- Company Logo, Name -->
<xsl:call-template name="Filler">
<xsl:with-param name="fillercount" select="1" />
</xsl:call-template>
<xsl:copy-of select="$middleSection"/> <!-- Section to specify Additional Details -->
<xsl:call-template name="Filler">
<xsl:with-param name="fillercount" select="1" />
</xsl:call-template>
<xsl:copy-of select="$ContentTableHeader"/>
<xsl:for-each select="Columns/Column">
<table class="tabledetails" cellspacing="0" style="table-layout:fixed" border="2">
<tr>
<td>
<xsl:value-of select="@Name" />
</td>
<td>
<xsl:variable name="BatchDetails" select="@Name"/>
<xsl:value-of select="../../Row/*[local-name()=$BatchDetails]"/>
<xsl:value-of select="translate(' ', ' ', ' ')"/>
</td>
</tr>
</table>
<xsl:if test="(position() mod 5) = 0 ">
<!--5 rows per page-->
<xsl:call-template name="Filler">
<xsl:with-param name="fillercount" select="1" />
</xsl:call-template>
<xsl:copy-of select="$ReportFooter" />
<br class="pagebreak" />
<xsl:copy-of select="$ReportHeader" />
<xsl:call-template name="Filler">
<xsl:with-param name="fillercount" select="1" />
</xsl:call-template>
<xsl:copy-of select="$middleSection"/> <!-- Section to specify Additional Details -->
<xsl:call-template name="Filler">
<xsl:with-param name="fillercount" select="1" />
</xsl:call-template>
<xsl:copy-of select="$ContentTableHeader"/>
</xsl:if>
</xsl:for-each>
</body>
</html>
</xsl:template>
<!-- ContentTableHeader -->
<xsl:variable name="ContentTableHeader">
<table class="tabledetails" cellspacing="0" style="table-layout:fixed" border="2">
<tr>
<th colspan="2">
In Process Batch Details
</th>
</tr>
</table>
</xsl:variable>
<!-- variable Miidle Section-->
<xsl:variable name="middleSection">
<table class="tabledetails" cellspacing="0" style="table-layout:fixed">
<tr>
<td class="tdmargin" />
<td class="documentheader" align="right">
Batch #:
<xsl:value-of select="translate(' ', ' ', ' ')"/>
</td>
<td>
<xsl:value-of select="//Row/BatchNumber"/>
<xsl:value-of select="translate(' ', ' ', ' ')"/>
</td>
<td class="documentheader" align="right">
Reviewer Name:
<xsl:value-of select="translate(' ', ' ', ' ')"/>
</td>
<td>
<xsl:value-of select="//Row/ReviewerName" />
<xsl:value-of select="translate(' ', ' ', ' ')"/>
</td>
<td class="tdmargin" />
</tr>
</table>
</xsl:variable>
<!-- variable ReportHeader-->
<xsl:variable name="ReportHeader">
<table class="tableReportHeader" cellspacing="0">
<tr>
<td>
<img class="imglogo" src="report1.bmp" />
</td>
<td align="center">
<img src="ABC_Company.gif" />
</td>
<td ALIGN="right">
<h3 style="color:darkblue; font-family: Arial;">BATCH DETAILS REPORT</h3>
</td>
</tr>
</table>
</xsl:variable>
<!-- Template Filler-->
<xsl:template name="Filler">
<xsl:param name="fillercount" select="1"/>
<xsl:if test="$fillercount > 0">
<table class="tabledetails">
<tr>
<td>
<xsl:value-of select="translate(' ', ' ', ' ')"/>
</td>
</tr>
</table>
<xsl:call-template name="Filler">
<xsl:with-param name="fillercount" select="$fillercount - 1"/>
</xsl:call-template>
</xsl:if>
</xsl:template>
<!-- variable ReportFooter-->
<xsl:variable name="ReportFooter">
<table class="tableReportFooter">
<tr>
<td style="width:20px;"></td>
<td>
<table>
<tr>
<td style="font-size:8pt; text-align: justify;border-top: solid #4A6ACC 1px;">
Footer Details for Example Phone:123456789 Fax:12345 Mail to : abc@xyz.com
</td>
</tr>
</table>
</td>
<td style="width:20px;"></td>
</tr>
</table>
</xsl:variable>
</xsl:stylesheet>
I am a facing the problem like in XMl if u observe i have 20 records exactly and in my XSLT i have written a logic to show only five records per page, when i iterate through the loop , i have to implement a logic
if the record position is last and and the total record count is exactly divisible by 5 then i should break the loop, so that i will not display the header template which is not needed.
Please find the attachment for clear under standing of the problem.
I dont need the last Page in the report as shown in the screen shot.