|
next
|
 Subject: Help : Display Tabular Data (with no repetitive data) Author: Nad ine Date: 23 Jan 2005 09:49 PM
|
I have an xml document like below-->
<?xml version="1.0" encoding="ISO8859-1" ?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<Attempts>
<Attempt StartTime="20041018 082300" DocSerialNum="A10374283" EndTime="20041018 082601">
<Screen Id="1" StartTime="082300" KeysPressed="Left3" />
<Screen Id="38" StartTime="082300" KeysPressed="Left2" />
<Screen Id="2" StartTime="082302" KeysPressed="Left3" />
<Screen Id="3" StartTime="082311" KeysPressed="Left3" />
<Screen Id="44" StartTime="082317" KeysPressed="0" />
<Screen Id="44" StartTime="082436" KeysPressed="1" />
<Screen Id="44" StartTime="082436" KeysPressed="6" />
<Screen Id="44" StartTime="082437" KeysPressed="2" />
<Screen Id="44" StartTime="082438" KeysPressed="2" />
<Screen Id="44" StartTime="082439" KeysPressed="1" />
<Screen Id="44" StartTime="082440" KeysPressed="8" />
<Screen Id="44" StartTime="082441" KeysPressed="7" />
<Screen Id="44" StartTime="082442" KeysPressed="3" />
<Screen Id="44" StartTime="082443" KeysPressed="5" />
<Screen Id="44" StartTime="082444" KeysPressed="Left2" />
<Screen Id="45" StartTime="082446" KeysPressed="Left3" />
<Screen Id="21" StartTime="082510" KeysPressed="Left2">
<Data Label="Print Error" Value="MethodTag: 5" />
<Data Label="BNA CancelOperation" Value="Request ID =5" />
</Screen>
</Attempt>
<Attempt StartTime="20041019 092300" DocSerialNum="A10374283" EndTime="20041019 102601">
<Screen Id="1" StartTime="082300" KeysPressed="Left3" />
<Screen Id="38" StartTime="082300" KeysPressed="Left2" />
<Screen Id="2" StartTime="082302" KeysPressed="Left3" />
<Screen Id="3" StartTime="082311" KeysPressed="Left3" />
<Screen Id="44" StartTime="082317" KeysPressed="0" />
<Screen Id="44" StartTime="082436" KeysPressed="1" />
<Screen Id="44" StartTime="082436" KeysPressed="6" />
<Screen Id="44" StartTime="082437" KeysPressed="2" />
<Screen Id="44" StartTime="082438" KeysPressed="2" />
<Screen Id="44" StartTime="082439" KeysPressed="1" />
<Screen Id="44" StartTime="082440" KeysPressed="8" />
<Screen Id="44" StartTime="082441" KeysPressed="7" />
<Screen Id="44" StartTime="082442" KeysPressed="3" />
<Screen Id="44" StartTime="082443" KeysPressed="5" />
<Screen Id="44" StartTime="082444" KeysPressed="Left2" />
<Screen Id="45" StartTime="082446" KeysPressed="Left3" />
<Screen Id="21" StartTime="082510" KeysPressed="Left2">
<Data Label="Print Pass" Value="MethodTag: 8" />
<Data Label="Completed" Value="Request ID =3" />
</Screen>
</Attempt>
<Attempt StartTime="20041020 102300" DocSerialNum="A44374283" EndTime="20041020 112601">
<Screen Id="1" StartTime="082300" KeysPressed="Left3" />
<Screen Id="38" StartTime="082300" KeysPressed="Left2" />
<Screen Id="2" StartTime="082302" KeysPressed="Left3" />
<Screen Id="3" StartTime="082311" KeysPressed="Left3" />
<Screen Id="44" StartTime="082317" KeysPressed="0" />
<Screen Id="44" StartTime="082436" KeysPressed="1" />
<Screen Id="44" StartTime="082436" KeysPressed="6" />
<Screen Id="44" StartTime="082437" KeysPressed="2" />
<Screen Id="44" StartTime="082438" KeysPressed="2" />
<Screen Id="44" StartTime="082439" KeysPressed="1" />
<Screen Id="44" StartTime="082440" KeysPressed="8" />
<Screen Id="44" StartTime="082441" KeysPressed="7" />
<Screen Id="44" StartTime="082442" KeysPressed="3" />
<Screen Id="44" StartTime="082443" KeysPressed="5" />
<Screen Id="44" StartTime="082444" KeysPressed="Left2" />
<Screen Id="45" StartTime="082446" KeysPressed="Left3" />
<Screen Id="21" StartTime="082510" KeysPressed="Left2">
<Data Label="Print Pass" Value="MethodTag: 8" />
<Data Label="Completed" Value="Request ID =3" />
</Screen>
</Attempt>
</Attempts>
I have tried to convert them to html table by using xsl. I am able to display those data
but there is a repetition data in the display HTML table. I want to display one single data only in a row,
by mean that i want to display the data based on DocSerialNum. Please guide me to do this.
Really appreciate your help.
Below is the created xsl document -->
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:template match="/">
<style type="text/css">
BODY {
MARGIN: 0px; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px FONT-SIZE: 10px
}
TABLE {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
TR {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
TD {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
DIV {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
</style>
<table border="1">
<tr>
<th align="middle">Date dd/mm/yyyy</th>
<th align="middle">Start Time hh:mm:ss</th>
<th align="middle">End time hh:mm:ss</th>
<th align="middle">Doc Serial Number No</th>
<th align="middle">Interval (minutes)</th>
<th align="middle">Error Encountered</th>
</tr>
<xsl:for-each select="Attempts/Attempt">
<xsl:variable name="errorName" select="(@Label)"/>
<xsl:variable name="temp2" select="0" />
<xsl:variable name="date" select="substring(@StartTime,1,15)"/>
<xsl:variable name="date2" select="substring(@EndTime,1,15)"/>
<tr>
<!-- to diplay starttime-->
<td><xsl:value-of select="concat(substring($date, 7,2),'/',substring($date, 5, 2),'/',substring($date, 1,4))"/></td>
<td align="left"><xsl:value-of select="concat(substring($date,10,2),':',substring($date,12,2),':',substring($date,14,2))"/></td>
<!-- to diplay endtime-->
<td align="left"><xsl:value-of select="concat(substring($date2,10,2),':',substring($date2,12,2),':',substring($date2,14,2))"/></td>
<!-- to diplay Document No-->
<!-- <td><xsl:value-of select="not(@DocSerialNum)"/></td>-->
<td>
<xsl:choose>
<xsl:when test="substring(@DocSerialNum,1,9)">
<xsl:value-of select="substring(@DocSerialNum,1,9)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>-</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
<!-- to diplay interval time-->
<td align="left"><xsl:value-of select="round(substring(@EndTime,10,6) div 60 - substring(@StartTime,10,6) div 60)"/></td>
<!-- to diplay error *testing-->
<td>
<xsl:choose>
<xsl:when test="Screen/Data[@Label = 'Print Error']">
<xsl:value-of select="$errorName"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>no error</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
Report finish......
</xsl:template>
</xsl:stylesheet>
|
next
|
 Subject: Help : Display Tabular Data (with no repetitive data) Author: Nad ine Date: 25 Jan 2005 09:25 PM
|
Thank you Ivan for the answer.
I've tried to apply to my existing xsl document like at the bottom of this.
But unluckly, my xml document unable to load and receive error of
"A string literal was not closed. Attempts/Attempt[generate-id() = generate-id(key(-->'DocSerialNum_To_Attemp_Map, @DocSeri..."
I'm not pretty sure about the way i put the key statement.
Please help me, i'm a newbie in this xml and xsl world.
Appreciate any help or suggestion which could guide me to be better.
Thank you in advanced.
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" />
<xsl:key name="DocSerialNum_To_Attemp_Map" match="Attempts/Attempt" use="@DocSerialNum"/>
<xsl:template match="/">
<style type="text/css">
BODY {
MARGIN: 0px; PADDING-BOTTOM: 0px; PADDING-LEFT: 0px; PADDING-RIGHT: 0px; PADDING-TOP: 0px FONT-SIZE: 10px
}
TABLE {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
TR {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
TD {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
DIV {
FONT-FAMILY: "Verdana", "Geneva", "Arial", "Sans-Serif"; FONT-SIZE: 10px
}
</style>
<table border="1">
<tr>
<th align="middle">Date dd/mm/yyyy</th>
<th align="middle">Start Time hh:mm:ss</th>
<th align="middle">End time hh:mm:ss</th>
<th align="middle">Doc Serial Number No</th>
<th align="middle">Interval (minutes)</th>
<th align="middle">Error Encountered</th>
</tr>
<!-- create a map with all the DocSerialNum values -->
<xsl:for-each select="Attempts/Attempt[generate-id() = generate-id(key('DocSerialNum_To_Attemp_Map, @DocSerialNum)[1])]">
<xsl:variable name="errorName" select="(@Label)"/>
<xsl:variable name="temp2" select="0" />
<xsl:variable name="date" select="substring(@StartTime,1,15)"/>
<xsl:variable name="date2" select="substring(@EndTime,1,15)"/>
<tr>
<!-- to diplay starttime-->
<td><xsl:value-of select="concat(substring($date, 7,2),'/',substring($date, 5, 2),'/',substring($date, 1,4))"/></td>
<td align="left"><xsl:value-of select="concat(substring($date,10,2),':',substring($date,12,2),':',substring($date,14,2))"/></td>
<!-- to diplay endtime-->
<td align="left"><xsl:value-of select="concat(substring($date2,10,2),':',substring($date2,12,2),':',substring($date2,14,2))"/></td>
<!-- to diplay Document No-->
<td>
<xsl:choose>
<xsl:when test="substring(@DocSerialNum,1,9)">
<xsl:value-of select="substring(@DocSerialNum,1,9)"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>-</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
<!-- to diplay interval time-->
<td align="left"><xsl:value-of select="round(substring(@EndTime,10,6) div 60 - substring(@StartTime,10,6) div 60)"/></td>
<!-- to diplay error *testing-->
<td>
<xsl:choose>
<xsl:when test="Screen/Data[@Label = 'Print Error']">
<xsl:value-of select="$errorName"/>
</xsl:when>
<xsl:otherwise>
<xsl:text>no error</xsl:text>
</xsl:otherwise>
</xsl:choose>
</td>
</tr>
</xsl:for-each>
</table>
Report finish......
</xsl:template>
</xsl:stylesheet>
|
|
|
|