<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="4.0" encoding="ISO-8859-1" media-type="text/html"/>
<!--root-->
<!--
    Stylesheet for daily event report (for English version)								** differ from event.xsl (1/7)

    Version 1.0.0.9

    Attention Logo: Placeholder "./logo.png" will be replaced from the caller of the
                    style sheet! (for example with "./logo.gif")
                    Details see Online Help chapter "Creation of individual network report"

	02.04.2007 Pietsch FGH Version 1.0.0.0
	05.09.2007 Pietsch Version 1.0.0.1
	27.11.2007 Noppatee
	11.12.2007 Noppatee		Failure occasion
    03.03.2008 Pietsch: details of affected station (transmission line/transformer)
    10.03.2008          supply interruptions
    25.03.2008          switching order with affected
    25.04.2008          first and last edit with local time format
	27.05.2008 Noppatee		Layout adjustment
	03.06.2008 Noppatee		Layout adjustment
    10.06.2008 Pietsch  e_d_v_rl_bc_dati with attribute "time_loc"
    29.07.2008 Noppatee	template "e_d_l_equipment" with attribute "component" (also layout adjustment)
    					template "switching_of_affected" with attribute "component" (also layout adjustment)
    03.08.2008 Noppatee	template "e_d_l_equipment" : switching order belonging to station
    													- type of component  = CB	-> aftype = 0
    													- type of component != CB	-> aftype = 99
    12.09.2008 Noppatee	Version 1.0.0.6
    					- all affected -> begin & end -> omit date if can (only time will be shown)
    					- paste ARC's operation only at the first CB
    					- switching order -> omit 'type of component'
    					- relay -> phase display -> omit '-' if no phase is shown
    					- move down 'occasion' into before 'details'
    					- if (1)'kind of event' = 'other' (2)'occasion' = 'egat', then show 'kind of event' = EGAT
    					- if 'kind of event' = 'visiting', then not show 'occasion'
    					- if 'kind of event' = 'other', then not show 'occasion'
    					     ** except in the case 'occasion' = 'egat'
    					- template "e_ev_fire" : change words 'Duration of fire' into 'Outage duration'
    					- if time = ?:??:??, then display 0?:??:??
    						- in switching order
    						- in affected
    23.09.2008 Noppatee	Version 1.0.0.7
    					- omit showing	-> Checking status
    									-> Event's ID
    									-> Chain status
    									-> District
    									-> (With/without switching)
    					- layout changement at
    						- line for separating events
    						- document showing
    						- header and footer of report
    						- Informed person
    						- template "e_ev_work", "si_list", "e_ev_other", "e_ev_problem", "event_information"
    						- template "aff_station_tm", "aff_station_tr", "aff_station", "aff_customer", "aff_feeder"
    01.10.2008 Noppatee	Version 1.0.0.8
    	- change from "." into "./@th_name" at template 'e_ev_outage', 'e_d_l_station', 'aff_station_tm', 'aff_station_tr', 'aff_station'
    		- add template 'long_interr' (due to "./@duration") at template 'aff_station_tm', 'aff_station_tr', 'aff_station', 'aff_customer', 'aff_feeder'
    16.10.2008 Noppatee	Version 1.0.0.9
    	1. change font from 'tohoma (9pt)' to 'angsana new (14pt)'
    	2. display station name by bold font
    	3. move 'Affect to supply interruption at...' to be displayed below 'switching order'
    		(moving some codes in template 'aff_station_tm', 'aff_station_tr', 'aff_station', 'aff_customer', 'aff_feeder'
    		to new template 'interr_...')
    	4. template 'e_d_l_equipment' and 'switching_of_affected' -> $eq_type='-'
    		-> if $remark is "> ???" , then ??? will be displayed in the second column
		5. cancel in omit showing 'Event's ID' and 'Chain status'
		6. W/P event -> move 'details' to be displayed before 'station' (-> result to loss of line by line)
		7. W/P event -> work inside station (no line or feeder entering) -> begin with station name
		 			 -> work outside station (having line or feeder entering) -> begin with name of line or feeder
		8. Busbar and Transformer event -> begin with station name
		   Power system outage event -> begin with EGAT, or station name, or customer name, or tr.line name
		9. using red letters for begining -> in
			'Transmission line, Feeder, Busbar, Transformer, Power system outage' event
		10. fill tag <pre></pre> for -> e_d_x_comment (but not for template 'wp_details')
		11. shift to second column for auto.function showing
		12. template 'event_information' -> swaping position
		13. more spaces in switching order (template 'e_d_l_equipment' and 'switching_of_affected')
		14. layout of template 'e_d_l_affected'
		15. omit in showing code number of occasion
		16. template "e_ev_fire" -> outage duration
		17. template "e_ev_feeder", template "e_ev_tmline"  -> call-template name="relay_not_shown"
		18. daily report -> hide any event having name begining with "hide_"
    	19. informed person -> separated and display into 5 lines (for maximum) -> ';' is used for separation
-->

<!-- variable "txt_list" will be evaluted by INTERASS.
     We expect a SPACE separated list of file types (suffix,extension)
     Document files with these suffixes will be treated as textfiles,
     otherwise a link will be shown
-->
<xsl:variable name="txt_list">log txt</xsl:variable>

<!-- variable "img_list"
     We expect a SPACE separated list of file types (suffix,extension)
     Document files with these suffixes will be treated as IMG files,
     otherwise a link will be shown
-->
<xsl:variable name="img_list">bmp gif jpg png</xsl:variable>

<xsl:template match="*|/">
	<html>
		<xsl:apply-templates select="Event-Data"/>
	</html>
</xsl:template>

<xsl:template match="Event-Data">
	<head>
		<title>Daily Event Report</title>												<!--** differ from event.xsl (2/7)-->
	</head>
	<body>
		<xsl:variable name="report_controlcenter" select="e_d_s_controlcenter/@text"/>	<!--** differ from event.xsl (3/7) #begin-->
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="left"><FONT face="tohoma" style="font-size: 9pt"><b><nobr>
         			Date:&#160;<xsl:value-of select="e_d_u_eventdate"/>
         		</nobr></b></FONT></td>
				<td align="right"><FONT face="tohoma" style="font-size: 9pt"><b><nobr>
         			<xsl:value-of select="$report_controlcenter"/>
         		</nobr></b></FONT></td>
			</tr>
		</table>
		<hr width="100%" align="CENTER" size="1" color="black"></hr>
		<BR></BR>
		<xsl:apply-templates select="Event">
			<xsl:with-param name="report_controlcenter" select="$report_controlcenter"/>
		</xsl:apply-templates>															<!--** differ from event.xsl (3/7) #end-->
		<!--footnote-->
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="right"><FONT face="angsana new" style="font-size: 14pt"><i>
					<nobr>Created at:&#160;<xsl:value-of select="datum"/></nobr>
					&#160;
					<nobr><xsl:value-of select="uhrzeit"/></nobr>
				</i></FONT></td>
			</tr>
		</table>
	</body>
</xsl:template>

<xsl:template match="Event">
	<xsl:param name="report_controlcenter"/>											<!--** differ from event.xsl (4/7)-->
	<xsl:variable name="eventdate" select="general/e_d_u_eventdate"/>
	<xsl:variable name="eventtime" select="general/e_d_v_eventtime"/>
	<xsl:variable name="occasion" select="general/e_d_s_anlass"/>
	<xsl:variable name="kindevent" select="general/e_d_e_kindevent"/>
	<xsl:variable name="eventname" select="general/e_d_s_eventname"/>					<!--** differ from event.xsl (5/7) #begin-->
	<xsl:variable name="begin_eventname" select="substring-before($eventname, '_')"/>
	<xsl:if test="$begin_eventname != 'hide'">											<!--** differ from event.xsl (5/7) #end-->
	<table width="100%" border="0">
		<tr bgcolor="#ffffff"><td align="center">
			<FONT face="angsana new" style="font-size: 14pt"><b><nobr>
				Event's name: <xsl:value-of select="general/e_d_s_eventname"/>&#160;[
				<!--if (1)'kind of event' = 'other' (2)'occasion' = 'egat', then show 'kind of event' = EGAT-->
				<xsl:choose><xsl:when test="starts-with($kindevent,9) + starts-with($occasion,7)='2'">
					EGAT
				</xsl:when><xsl:otherwise>
					<xsl:value-of select="general/e_d_e_kindevent/@text"/>
				</xsl:otherwise></xsl:choose>
				]
			</nobr></b></FONT>
		</td></tr>
		<xsl:if test="general/e_d_s_controlcenter/@text != $report_controlcenter">		<!--** differ from event.xsl (6/7) #begin-->
			<tr bgcolor="#ffffff"><td align="center">
				<FONT face="tohoma" style="font-size: 9pt"><i><nobr>
					<xsl:value-of select="general/e_d_s_controlcenter/@text"/>
				</nobr></i></FONT>
			</td></tr>
		</xsl:if>																		<!--** differ from event.xsl (6/7) #end-->
		<tr bgcolor="#ffffff"><td align="center">
			<FONT face="angsana new" style="font-size: 12pt"><nobr>
				Event's ID = <xsl:value-of select="general/e_d_i_evrid"/>
				( Chain status: <xsl:value-of select="general/e_d_e_kindchain/@text"/>
				<xsl:variable name="e_d_e_kindchain" select="general/e_d_e_kindchain"/>
				<xsl:choose><xsl:when test="$e_d_e_kindchain='2'">
					" Preceding event's ID = <xsl:value-of select="general/e_d_i_chainprevid"/> "
				</xsl:when><xsl:when test="$e_d_e_kindchain='3'">
					" Preceding event's ID = <xsl:value-of select="general/e_d_i_chainprevid"/> "
				</xsl:when></xsl:choose>)
			</nobr></FONT>
		</td></tr>
		<tr bgcolor="#ffffff"><td align="center">
			&#160;
		</td></tr>
		<tr bgcolor="#ffffff"><td align="right">
			<FONT face="angsana new" style="font-size: 14pt"><nobr>
				Date last change: <xsl:value-of select="general/e_d_v_lastedit_date/@text"/>
				&#160;(Editor: <xsl:value-of select="general/e_d_s_lastedit_name"/>)
			</nobr></FONT>
		</td></tr>
		<tr bgcolor="#ffffff"><td align="right">
			<FONT face="angsana new" style="font-size: 14pt"><nobr>
				Date first change: <xsl:value-of select="general/e_d_v_firstedit_date/@text"/>
				&#160;(Editor: <xsl:value-of select="general/e_d_s_firstedit_name"/>)
			</nobr></FONT>
		</td></tr>
		<!--<tr bgcolor="#ffffff"><td align="right">
			<FONT face="angsana new" style="font-size: 14pt"><nobr>
				Checking status: <xsl:value-of select="general/e_d_e_status/@text"/>
			</nobr></FONT>
		</td></tr>-->
		<tr bgcolor="#ffffff"><td align="left">
			&#160;
		</td></tr>
		<tr bgcolor="#ffffff"><td align="left">
			<FONT face="angsana new" style="font-size: 14pt"><nobr>
				Event's time: <xsl:value-of select="$eventdate"/>&#160;<xsl:copy-of select="$eventtime"/>
			</nobr></FONT>
		</td></tr>
	</table>
	<BR></BR>
	<xsl:variable name="superior" select="general/e_d_b_superior"/>
	<xsl:variable name="important" select="general/e_d_b_important"/>
	<xsl:variable name="informedperson" select="general/e_d_s_informedperson"/>
	<xsl:variable name="e_d_x_comment" select="e_d_x_comment"/>

	<xsl:apply-templates select="e_ev_undef"/>

	<!--e_ev_tmline		(0: Transmission line event)-->
	<xsl:apply-templates select="e_ev_tmline">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_feeder		(1: Feeder event)-->
	<xsl:apply-templates select="e_ev_feeder">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_busbar		(2: Busbar event)-->
	<xsl:apply-templates select="e_ev_busbar">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_trafo		(3: Transformer event)-->
	<xsl:apply-templates select="e_ev_trafo">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_work		(4: Work permit event)-->
	<xsl:apply-templates select="e_ev_work">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
		<xsl:with-param name="e_d_x_comment"><xsl:value-of select="$e_d_x_comment"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_fire		(5: Fire event)-->
	<xsl:apply-templates select="e_ev_fire">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_problem	(6: Equipment problems event)-->
	<xsl:apply-templates select="e_ev_problem">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_staff		(7: Staff / Non-staff visit event)-->
	<xsl:apply-templates select="e_ev_staff">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_outage		(8: Power system outage event)-->
	<xsl:apply-templates select="e_ev_outage">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--e_ev_other		(9: Other event)-->
	<xsl:apply-templates select="e_ev_other">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		<xsl:with-param name="eventtime"><xsl:value-of select="$eventtime"/></xsl:with-param>
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:apply-templates>

	<!--supply interruptions-->
	<xsl:apply-templates select="si_list"/>

    <!--
    - if 'kind of event' = 'visiting', then not show 'occasion'
    - if 'kind of event' = 'other', then not show 'occasion'
         ** except in the case 'occasion' = 'egat'
    -->
	<xsl:choose><xsl:when test="$kindevent != '7'">
		<xsl:choose><xsl:when test="$kindevent != '9'">
			<table border="0">
				<xsl:choose><xsl:when test="$occasion">
					<BR></BR>
					<tr bgcolor="#ffffff">
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr><b>Occasion:</b></nobr></FONT></td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							<!--[<xsl:value-of select="$occasion"/>]-->
							<xsl:value-of select="general/e_d_s_anlass/@text"/>
						</nobr></FONT></td>
					</tr>
				</xsl:when></xsl:choose>
			</table>
		</xsl:when></xsl:choose>
	</xsl:when></xsl:choose>
	<xsl:choose><xsl:when test="starts-with($kindevent,9) + starts-with($occasion,7) = '2'">
		<table border="0">
			<xsl:choose><xsl:when test="$occasion">
				<BR></BR>
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><b>Occasion:</b></nobr></FONT></td>
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						<!--[<xsl:value-of select="$occasion"/>]-->
						<xsl:value-of select="general/e_d_s_anlass/@text"/>
					</nobr></FONT></td>
				</tr>
			</xsl:when></xsl:choose>
		</table>
	</xsl:when></xsl:choose>

	<!--this will not be used in W/P event-->
	<xsl:if test="$kindevent != '4'">
		<xsl:choose><xsl:when test="$e_d_x_comment">
			<BR></BR>
			<pre>
				<FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;<b>Details</b></nobr></FONT>
				<xsl:for-each select="e_d_x_comment/item">
					<FONT face="angsana new" style="font-size: 14pt">&#160;&#160;&#160;<xsl:value-of select="."/></FONT>
				</xsl:for-each>
			</pre>
		</xsl:when></xsl:choose>
	</xsl:if>

  	<xsl:variable name="bv7" select="e_d_l_document"/>
	<xsl:choose><xsl:when test="$bv7">
		<BR></BR>
		<table border="0">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><b>Documents</b></nobr></FONT></td>
			</tr>
			<xsl:for-each select="e_d_l_document/doc">
	    		<xsl:variable name="vopt" select="./@type"/>
	    		<xsl:call-template name="test_txt_filetypes">
	        		<xsl:with-param name="list"><xsl:value-of select="$txt_list"/></xsl:with-param>
	        		<xsl:with-param name="ist_typ"><xsl:value-of select="$vopt"/></xsl:with-param>
	        		<xsl:with-param name="cur_name" select="."/>
	        		<xsl:with-param name="cur_desc" select="./@desc"/>
				</xsl:call-template>
			</xsl:for-each>
		</table>
	</xsl:when></xsl:choose>
	
	<BR></BR>
	<hr width="75%" align="CENTER" size="1" color="black"></hr>
	<BR></BR>
	</xsl:if>																			<!--** differ from event.xsl (7/7)-->
</xsl:template>

<!--e_ev_undef		(Undefined event)-->
<xsl:template match="e_ev_undef">
	<table border="0">
	</table>
</xsl:template>

<!--e_ev_tmline   	(0: Transmission line event)-->
<xsl:template match="e_ev_tmline">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="e_d_l_line" select="e_d_l_line"/>
	<xsl:choose><xsl:when test="$e_d_l_line">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
					Transmission line&#160;
					<xsl:for-each select="e_d_l_line/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
		<BR></BR>
	</xsl:when></xsl:choose>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
  	<table border="0">
		<tr bgcolor="#ffffff">
			<td valign="TOP"><FONT face="angsana new" style="font-size: 14pt">
				<nobr>&#160;&#160;&#160;&#160;<xsl:copy-of select="$eventtime"/></nobr>
			</FONT></td>
			<td><table border="0">
				<xsl:variable name="e_d_b_rl_rr" select="e_d_b_relais/e_d_b_rl_rr"/>
				<xsl:variable name="e_d_b_rl_rr_off" select="e_d_b_relais/e_d_b_rl_rr_off"/>
				<xsl:variable name="rr_state" select="e_d_b_relais/e_d_e_rl_rr_state/@type"/>
				<xsl:for-each select="e_d_l_breaker/breaker">
					<tr bgcolor="#ffffff">
			    		<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="."/></nobr></FONT></td>
			    		<xsl:choose><xsl:when test="position()='1'">
			    			<!--for the first CB:-->
			    			<!--if having RR's operating result, then show RR's operating result-->
			    			<!--otherwise, then show status of CB-->
			    			<xsl:choose><xsl:when test="$e_d_b_rl_rr='1'">
			    				<xsl:choose><xsl:when test="$rr_state">
			    					<xsl:choose><xsl:when test="$e_d_b_rl_rr_off='0'">
											<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr><xsl:value-of select="$rr_state"/></nobr></i></FONT></td>
			    					</xsl:when><xsl:otherwise>
			    							<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
									</xsl:otherwise></xsl:choose>
			    				</xsl:when><xsl:otherwise>
			    						<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
								</xsl:otherwise></xsl:choose>
			    			</xsl:when><xsl:otherwise>
			    				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
							</xsl:otherwise></xsl:choose>
						</xsl:when><xsl:otherwise>
							<!--for the other CBs, always show their CBs's status-->
							<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
						</xsl:otherwise></xsl:choose>
    				</tr>
  				</xsl:for-each>
  				<xsl:variable name="bv8" select="e_d_b_relais"/>
				<xsl:choose><xsl:when test="$bv8">
					<xsl:variable name="e_d_b_rl_notshown" select="e_d_b_relais/e_d_b_rl_notshown"/>
					<xsl:choose><xsl:when test="$e_d_b_rl_notshown='0'">
						<xsl:call-template name="distance_relay"></xsl:call-template>
						<xsl:call-template name="oc_relay"></xsl:call-template>
						<xsl:call-template name="ef_relay"></xsl:call-template>
						<xsl:call-template name="currdiff_relay"></xsl:call-template>
							<xsl:choose><xsl:when test="e_d_b_relais/e_d_b_rl_dr='0' and e_d_b_relais/e_d_b_rl_oc='0' and e_d_b_relais/e_d_b_rl_ef='0' and e_d_b_relais/e_d_b_rl_cu='0'">
							<xsl:call-template name="relay_not_shown"></xsl:call-template>
						</xsl:when></xsl:choose>
			    		<xsl:call-template name="rr_relay">
							<xsl:with-param name="e_d_b_rl_rr"><xsl:value-of select="$e_d_b_rl_rr"/></xsl:with-param>
							<xsl:with-param name="e_d_b_rl_rr_off"><xsl:value-of select="$e_d_b_rl_rr_off"/></xsl:with-param>
			    		</xsl:call-template>
					</xsl:when><xsl:otherwise>
						<xsl:call-template name="relay_not_shown"></xsl:call-template>
					</xsl:otherwise></xsl:choose>
				</xsl:when></xsl:choose>
  			</table></td>
		</tr>
	</table>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--summary of affected from this interr. transmission line (if have)-->
  	<xsl:variable name="bv5" select="e_d_l_affected"/>
	<xsl:choose><xsl:when test="$bv5">
		<table border="0">
			<tr bgcolor="#ffffff">
				<xsl:apply-templates select="e_d_l_line"/>
				<xsl:apply-templates select="e_d_l_affected"/>
			</tr>
		</table>
	</xsl:when></xsl:choose>
	<!--'affected stations' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_sta" select="e_d_l_affected/station_tm"/>
	<xsl:variable name="affected_list_sta" select="substring-after($pre_affected_list_sta, ' ')"/>
	<xsl:variable name="first_sta" select="substring-before($affected_list_sta, ' ')"/>
    <xsl:variable name="remaining_sta" select="substring-after($affected_list_sta, ' ')"/>
	<xsl:call-template name="aff_station_tm_with_switching">
		<xsl:with-param name="affected" select="$first_sta"/>
		<xsl:with-param name="remaining" select="$remaining_sta"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected HV customers' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_cust" select="e_d_l_affected/customer"/>
	<xsl:variable name="affected_list_cust" select="substring-after($pre_affected_list_cust, ' ')"/>
	<xsl:variable name="first_cust" select="substring-before($affected_list_cust, ' ')"/>
    <xsl:variable name="remaining_cust" select="substring-after($affected_list_cust, ' ')"/>
	<xsl:call-template name="aff_customer_with_switching">
		<xsl:with-param name="affected" select="$first_cust"/>
		<xsl:with-param name="remaining" select="$remaining_cust"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected feeders' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_fd" select="e_d_l_affected/feeder"/>
	<xsl:variable name="affected_list_fd" select="substring-after($pre_affected_list_fd, ' ')"/>
	<xsl:variable name="first_fd" select="substring-before($affected_list_fd, ' ')"/>
    <xsl:variable name="remaining_fd" select="substring-after($affected_list_fd, ' ')"/>
	<xsl:call-template name="aff_feeder_with_switching">
		<xsl:with-param name="affected" select="$first_fd"/>
		<xsl:with-param name="remaining" select="$remaining_fd"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_feeder		(1: Feeder event)-->
<xsl:template match="e_ev_feeder">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="feeder" select="e_d_l_breaker/feeder"/>
	<xsl:choose><xsl:when test="$feeder">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
					Feeder&#160;
					<xsl:for-each select="e_d_l_breaker/feeder">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
		<BR></BR>
	</xsl:when></xsl:choose>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
  	<table border="0">
		<tr bgcolor="#ffffff">
			<td valign="TOP"><FONT face="angsana new" style="font-size: 14pt">
				<nobr>&#160;&#160;&#160;&#160;<xsl:copy-of select="$eventtime"/></nobr>
			</FONT></td>
			<td><table border="0">
				<xsl:variable name="e_d_b_rl_rr" select="e_d_b_relais/e_d_b_rl_rr"/>
				<xsl:variable name="e_d_b_rl_rr_off" select="e_d_b_relais/e_d_b_rl_rr_off"/>
				<xsl:variable name="rr_state" select="e_d_b_relais/e_d_e_rl_rr_state/@type"/>
				<xsl:for-each select="e_d_l_breaker/feeder">
					<tr bgcolor="#ffffff">
			    		<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="."/></nobr></FONT></td>
			    		<xsl:choose><xsl:when test="position()='1'">
			    			<!--for the first CB:-->
			    			<!--if having RR's operating result, then show RR's operating result-->
			    			<!--otherwise, then show status of CB-->
			    			<xsl:choose><xsl:when test="$e_d_b_rl_rr='1'">
			    				<xsl:choose><xsl:when test="$rr_state">
			    					<xsl:choose><xsl:when test="$e_d_b_rl_rr_off='0'">
											<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr><xsl:value-of select="$rr_state"/></nobr></i></FONT></td>
			    					</xsl:when><xsl:otherwise>
			    							<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
									</xsl:otherwise></xsl:choose>
			    				</xsl:when><xsl:otherwise>
			    						<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
								</xsl:otherwise></xsl:choose>
			    			</xsl:when><xsl:otherwise>
			    				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
							</xsl:otherwise></xsl:choose>
						</xsl:when><xsl:otherwise>
							<!--for the other CBs, always show their CBs's status-->
							<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
						</xsl:otherwise></xsl:choose>
    				</tr>
  				</xsl:for-each>
  				<xsl:variable name="bv8" select="e_d_b_relais"/>
				<xsl:choose><xsl:when test="$bv8">
					<xsl:variable name="e_d_b_rl_notshown" select="e_d_b_relais/e_d_b_rl_notshown"/>
					<xsl:choose><xsl:when test="$e_d_b_rl_notshown='0'">
						<xsl:call-template name="oc_relay"></xsl:call-template>
						<xsl:call-template name="ef_relay"></xsl:call-template>
						<xsl:choose><xsl:when test="e_d_b_relais/e_d_b_rl_oc='0' and e_d_b_relais/e_d_b_rl_ef='0'">
							<xsl:call-template name="relay_not_shown"></xsl:call-template>
						</xsl:when></xsl:choose>
			    		<xsl:call-template name="rr_relay">
							<xsl:with-param name="e_d_b_rl_rr"><xsl:value-of select="$e_d_b_rl_rr"/></xsl:with-param>
							<xsl:with-param name="e_d_b_rl_rr_off"><xsl:value-of select="$e_d_b_rl_rr_off"/></xsl:with-param>
			    		</xsl:call-template>
					</xsl:when><xsl:otherwise>
						<xsl:call-template name="relay_not_shown"></xsl:call-template>
					</xsl:otherwise></xsl:choose>
				</xsl:when></xsl:choose>
  			</table></td>
		</tr>
		<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
			&#160;&#160;&#160;&#160;-<xsl:value-of select="e_d_d_loss"/>(<xsl:value-of select="e_d_d_current"/>)
		</nobr></FONT></td></tr>
	</table>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_busbar		(2: Busbar event)-->
<xsl:template match="e_ev_busbar">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="e_d_l_station" select="e_d_l_station"/>
	<xsl:if test="$e_d_l_station">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
					<xsl:for-each select="e_d_l_station/station">
			    		<xsl:choose><xsl:when test="./@th_name != ''">
			    			<xsl:value-of select="./@th_name"/>
			    		</xsl:when><xsl:otherwise>
			    			Station <xsl:value-of select="."/>
			    		</xsl:otherwise></xsl:choose>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:if>
	<BR></BR>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
  	<table border="0">
		<tr bgcolor="#ffffff">
			<td valign="TOP"><FONT face="angsana new" style="font-size: 14pt">
				<nobr>&#160;&#160;&#160;&#160;<xsl:copy-of select="$eventtime"/></nobr>
			</FONT></td>
			<td><table border="0">
				<xsl:for-each select="e_d_l_breaker/breaker">
					<tr bgcolor="#ffffff">
			    		<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="."/></nobr></FONT></td>
			    		<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
    				</tr>
  				</xsl:for-each>
  				<xsl:variable name="bv8" select="e_d_b_relais"/>
				<xsl:choose><xsl:when test="$bv8">
					<xsl:variable name="e_d_b_rl_notshown" select="e_d_b_relais/e_d_b_rl_notshown"/>
					<xsl:choose><xsl:when test="$e_d_b_rl_notshown='0'">
						<xsl:call-template name="bus_dif_relay"></xsl:call-template>
						<xsl:call-template name="breaker_fail"></xsl:call-template>
						<xsl:call-template name="oc_relay"></xsl:call-template>
						<xsl:call-template name="ef_relay"></xsl:call-template>
						<xsl:call-template name="ouv_relay"></xsl:call-template>
					</xsl:when><xsl:otherwise>
						<xsl:call-template name="relay_not_shown"></xsl:call-template>
					</xsl:otherwise></xsl:choose>
				</xsl:when></xsl:choose>
  			</table></td>
		</tr>
	</table>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--summary of affected from this interr. busbar (if have)-->
  	<xsl:variable name="bv5" select="e_d_l_affected"/>
	<xsl:choose><xsl:when test="$bv5">
		<table border="0">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr>Affects to</nobr></FONT></td>
				<xsl:apply-templates select="e_d_l_affected"/>
			</tr>
		</table>
	</xsl:when></xsl:choose>
	<!--'affected stations' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_sta" select="e_d_l_affected/station"/>
	<xsl:variable name="affected_list_sta" select="substring-after($pre_affected_list_sta, ' ')"/>
	<xsl:variable name="first_sta" select="substring-before($affected_list_sta, ' ')"/>
    <xsl:variable name="remaining_sta" select="substring-after($affected_list_sta, ' ')"/>
	<xsl:call-template name="aff_station_with_switching">
		<xsl:with-param name="affected" select="$first_sta"/>
		<xsl:with-param name="remaining" select="$remaining_sta"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected HV customers' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_cust" select="e_d_l_affected/customer"/>
	<xsl:variable name="affected_list_cust" select="substring-after($pre_affected_list_cust, ' ')"/>
	<xsl:variable name="first_cust" select="substring-before($affected_list_cust, ' ')"/>
    <xsl:variable name="remaining_cust" select="substring-after($affected_list_cust, ' ')"/>
	<xsl:call-template name="aff_customer_with_switching">
		<xsl:with-param name="affected" select="$first_cust"/>
		<xsl:with-param name="remaining" select="$remaining_cust"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected feeders' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_fd" select="e_d_l_affected/feeder"/>
	<xsl:variable name="affected_list_fd" select="substring-after($pre_affected_list_fd, ' ')"/>
	<xsl:variable name="first_fd" select="substring-before($affected_list_fd, ' ')"/>
    <xsl:variable name="remaining_fd" select="substring-after($affected_list_fd, ' ')"/>
	<xsl:call-template name="aff_feeder_with_switching">
		<xsl:with-param name="affected" select="$first_fd"/>
		<xsl:with-param name="remaining" select="$remaining_fd"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_trafo		(3: Transformer event)-->
<xsl:template match="e_ev_trafo">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="e_d_l_station" select="e_d_l_station"/>
	<xsl:if test="$e_d_l_station">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
					<xsl:for-each select="e_d_l_station/station">
			    		<xsl:choose><xsl:when test="./@th_name != ''">
			    			<xsl:value-of select="./@th_name"/>
			    		</xsl:when><xsl:otherwise>
			    			Station <xsl:value-of select="."/>
			    		</xsl:otherwise></xsl:choose>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:if>
	<BR></BR>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
  	<table border="0">
		<tr bgcolor="#ffffff">
			<td valign="TOP"><FONT face="angsana new" style="font-size: 14pt">
				<nobr>&#160;&#160;&#160;&#160;<xsl:copy-of select="$eventtime"/></nobr>
			</FONT></td>
			<td><table border="0">
				<xsl:for-each select="e_d_l_breaker/breaker">
					<tr bgcolor="#ffffff">
			    		<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="."/></nobr></FONT></td>
			    		<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="./@status"/></nobr></FONT></td>
    				</tr>
  				</xsl:for-each>
  				<xsl:variable name="bv8" select="e_d_b_relais"/>
				<xsl:choose><xsl:when test="$bv8">
					<xsl:variable name="e_d_b_rl_notshown" select="e_d_b_relais/e_d_b_rl_notshown"/>
					<xsl:choose><xsl:when test="$e_d_b_rl_notshown='0'">
						<xsl:call-template name="transf_dif_relay"></xsl:call-template>
						<xsl:call-template name="buchholz"></xsl:call-template>
						<xsl:call-template name="sudden_gas"></xsl:call-template>
						<xsl:call-template name="backup"></xsl:call-template>
						<xsl:call-template name="oc_relay"></xsl:call-template>
						<xsl:call-template name="ef_relay"></xsl:call-template>
						<xsl:call-template name="ouv_relay"></xsl:call-template>
					</xsl:when><xsl:otherwise>
						<xsl:call-template name="relay_not_shown"></xsl:call-template>
					</xsl:otherwise></xsl:choose>
				</xsl:when></xsl:choose>
  			</table></td>
		</tr>
	</table>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--summary of affected from this interr. transformer (if have)-->
  	<xsl:variable name="bv5" select="e_d_l_affected"/>
	<xsl:choose><xsl:when test="$bv5">
		<table border="0">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr>Affects to</nobr></FONT></td>
				<xsl:apply-templates select="e_d_l_affected"/>
			</tr>
		</table>
	</xsl:when></xsl:choose>
	<!--'affected stations' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_sta" select="e_d_l_affected/station_tr"/>
	<xsl:variable name="affected_list_sta" select="substring-after($pre_affected_list_sta, ' ')"/>
	<xsl:variable name="first_sta" select="substring-before($affected_list_sta, ' ')"/>
    <xsl:variable name="remaining_sta" select="substring-after($affected_list_sta, ' ')"/>
	<xsl:call-template name="aff_station_tr_with_switching">
		<xsl:with-param name="affected" select="$first_sta"/>
		<xsl:with-param name="remaining" select="$remaining_sta"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected HV customers' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_cust" select="e_d_l_affected/customer"/>
	<xsl:variable name="affected_list_cust" select="substring-after($pre_affected_list_cust, ' ')"/>
	<xsl:variable name="first_cust" select="substring-before($affected_list_cust, ' ')"/>
    <xsl:variable name="remaining_cust" select="substring-after($affected_list_cust, ' ')"/>
	<xsl:call-template name="aff_customer_with_switching">
		<xsl:with-param name="affected" select="$first_cust"/>
		<xsl:with-param name="remaining" select="$remaining_cust"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected feeders' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_fd" select="e_d_l_affected/feeder"/>
	<xsl:variable name="affected_list_fd" select="substring-after($pre_affected_list_fd, ' ')"/>
	<xsl:variable name="first_fd" select="substring-before($affected_list_fd, ' ')"/>
    <xsl:variable name="remaining_fd" select="substring-after($affected_list_fd, ' ')"/>
	<xsl:call-template name="aff_feeder_with_switching">
		<xsl:with-param name="affected" select="$first_fd"/>
		<xsl:with-param name="remaining" select="$remaining_fd"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_work		(4: Work permit event)-->
<xsl:template match="e_ev_work">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:param name="e_d_x_comment"/>
	<xsl:variable name="e_d_l_station" select="e_d_l_station"/>
	<xsl:variable name="e_d_l_line" select="e_d_l_line"/>
	<xsl:variable name="e_d_l_feeder" select="e_d_l_feeder"/>
	<xsl:choose><xsl:when test="$e_d_l_line">
	</xsl:when><xsl:otherwise>
		<xsl:choose><xsl:when test="$e_d_l_feeder">
		</xsl:when><xsl:otherwise>
			<xsl:if test="$e_d_l_station">
				<table width="100%" border="0">
					<tr bgcolor="#ffffff">
						<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
							<xsl:for-each select="e_d_l_station/station">
			    				<xsl:choose><xsl:when test="./@th_name != ''">
			    					<xsl:value-of select="./@th_name"/>
			    				</xsl:when><xsl:otherwise>
			    					Station <xsl:value-of select="."/>
			    				</xsl:otherwise></xsl:choose>
			    				<xsl:choose><xsl:when test="position() != last()">
			    					&#160;
			    				</xsl:when></xsl:choose>
  							</xsl:for-each>
  						</nobr></b></u></FONT></td>
  					</tr>
				</table>
			</xsl:if>
		</xsl:otherwise></xsl:choose>
	</xsl:otherwise></xsl:choose>
	<xsl:choose><xsl:when test="$e_d_l_line">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
					Transmission line&#160;
					<xsl:for-each select="e_d_l_line/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:when></xsl:choose>
	<xsl:choose><xsl:when test="$e_d_l_feeder">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
					Feeder&#160;
					<xsl:for-each select="e_d_l_feeder/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:when></xsl:choose>
	<table width="100%" border="0">
		<tr bgcolor="#ffffff"><td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>
  			<xsl:variable name="e_d_e_wp_type" select="e_d_e_wp_type"/>
			<xsl:choose><xsl:when test="$e_d_e_wp_type='0'">
				No W/P
			</xsl:when><xsl:when test="$e_d_e_wp_type='1'">
				W/P
			</xsl:when></xsl:choose>
			<xsl:value-of select="e_d_e_wp_respon/@type"/>
  			<!--<xsl:variable name="e_d_e_wp_switch" select="e_d_e_wp_switch"/>
			<xsl:choose><xsl:when test="$e_d_e_wp_switch='0'">
				(Without switching)
			</xsl:when><xsl:when test="$e_d_e_wp_switch='1'">
				(With switching)
			</xsl:when></xsl:choose>-->
		</nobr></FONT></td></tr>
	</table>
	<BR></BR>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="wp_details">
		<xsl:with-param name="e_d_x_comment" select="$e_d_x_comment"/>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_fire		(5: Fire event)-->
<xsl:template match="e_ev_fire">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
	<xsl:variable name="dur_hh" select="substring-before(e_d_d_duration/@hhmm, ':')"/>
	<xsl:variable name="dur_mm_ss" select="substring-after(e_d_d_duration/@hhmm, ':')"/>
	<xsl:variable name="dur_mm" select="substring-before($dur_mm_ss, ':')"/>
	<xsl:variable name="dur_ss" select="substring-after($dur_mm_ss, ':')"/>
	<table border="0">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr><xsl:copy-of select="$eventtime"/></nobr></i></FONT></td>
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Outage duration
				<xsl:if test="$dur_hh != 0">
					<xsl:choose><xsl:when test="starts-with($dur_hh,'0')">
						<xsl:value-of select="substring-after($dur_hh,'0')"/>
					</xsl:when><xsl:otherwise>
						<xsl:value-of select="$dur_hh"/>
					</xsl:otherwise></xsl:choose>
					hrs.
				</xsl:if>
				<xsl:if test="$dur_mm != '00'">
					<xsl:choose><xsl:when test="starts-with($dur_mm,'0')">
						<xsl:value-of select="substring-after($dur_mm,'0')"/>
					</xsl:when><xsl:otherwise>
						<xsl:value-of select="$dur_mm"/>
					</xsl:otherwise></xsl:choose>
					min.
				</xsl:if>
				<xsl:if test="$dur_ss != '00'">
					<xsl:choose><xsl:when test="starts-with($dur_ss,'0')">
						<xsl:value-of select="substring-after($dur_ss,'0')"/>
					</xsl:when><xsl:otherwise>
						<xsl:value-of select="$dur_ss"/>
					</xsl:otherwise></xsl:choose>
					sec.
				</xsl:if>
			</nobr></i></FONT></td>
		</tr>
	</table>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_problem	(6: Equipment problems event)-->
<xsl:template match="e_ev_problem">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="e_d_l_line" select="e_d_l_line"/>
	<xsl:choose><xsl:when test="$e_d_l_line">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
					Transmission line&#160;
					<xsl:for-each select="e_d_l_line/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
		<BR></BR>
	</xsl:when></xsl:choose>
	<xsl:variable name="e_d_l_feeder" select="e_d_l_feeder"/>
	<xsl:choose><xsl:when test="$e_d_l_feeder">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
					Feeder&#160;
					<xsl:for-each select="e_d_l_feeder/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:when></xsl:choose>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_staff		(7: Staff / Non-staff visit event)-->
<xsl:template match="e_ev_staff">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
	<table border="0">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr><xsl:copy-of select="$eventtime"/></nobr></i></FONT></td>
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Visited by "<xsl:value-of select="e_d_e_vi_type/@type"/>"</nobr></i></FONT></td>
		</tr>
	</table>
</xsl:template>

<!--e_ev_outage		(8: Power system outage event)-->
<xsl:template match="e_ev_outage">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="e_d_l_station" select="e_d_l_station"/>
	<xsl:variable name="e_d_l_customer" select="e_d_l_customer"/>
	<xsl:variable name="e_d_l_line" select="e_d_l_line"/>
  	<table width="100%" border="0">
		<tr bgcolor="#ffffff">
			<td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000">
				<u><b><nobr>Power system outage</nobr></b></u>
			</FONT></td>
		</tr>
		<xsl:variable name="e_d_b_eg_lo" select="e_d_b_eg_lo"/>
		<xsl:variable name="e_d_b_eg_uf" select="e_d_b_eg_uf"/>
		<xsl:variable name="summing" select="$e_d_b_eg_lo + $e_d_b_eg_uf"/>
		<xsl:if test="$summing &gt; 0">
			<tr bgcolor="#ffffff"><td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
				EGAT
				<xsl:if test="$e_d_b_eg_lo='1'">&#160;(Load shedding)</xsl:if>
				<xsl:if test="$e_d_b_eg_uf='1'">&#160;(UF relay)</xsl:if>
			</nobr></b></u></FONT></td></tr>
		</xsl:if>
		<xsl:if test="$e_d_l_station">
			<tr bgcolor="#ffffff"><td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
				<xsl:for-each select="e_d_l_station/station">
			    	<xsl:choose><xsl:when test="./@th_name != ''">
			    		<xsl:value-of select="./@th_name"/>
					</xsl:when><xsl:otherwise>
						Station <xsl:value-of select="."/>
					</xsl:otherwise></xsl:choose>
					(<xsl:value-of select="./@status"/>)
			    	<xsl:choose><xsl:when test="position() != last()">
			    		&#160;
			    	</xsl:when></xsl:choose>
  				</xsl:for-each>
  			</nobr></b></u></FONT></td></tr>
  		</xsl:if>
  		<xsl:if test="$e_d_l_customer">
  			<tr bgcolor="#ffffff"><td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
  				HV customer&#160;&#160;
  				<xsl:for-each select="e_d_l_customer/item">
			    	<xsl:value-of select="."/>
			    	<xsl:choose><xsl:when test="position() != last()">
			    		&#160;
			    	</xsl:when></xsl:choose>
  				</xsl:for-each>
  			</nobr></b></u></FONT></td></tr>
  		</xsl:if>
  		<xsl:if test="$e_d_l_line">
  			<tr bgcolor="#ffffff"><td align="center"><FONT face="angsana new" style="font-size: 14pt" color="#FF0000"><u><b><nobr>
  				Transmission line&#160;&#160;
  				<xsl:for-each select="e_d_l_line/item">
			    	<xsl:value-of select="."/>
			    	<xsl:choose><xsl:when test="position() != last()">
			    		&#160;
			    	</xsl:when></xsl:choose>
  				</xsl:for-each>
  			</nobr></b></u></FONT></td></tr>
  		</xsl:if>
	</table>
	<BR></BR>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<!--'affected stations' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_sta" select="e_d_l_affected/station"/>
	<xsl:variable name="affected_list_sta" select="substring-after($pre_affected_list_sta, ' ')"/>
	<xsl:variable name="first_sta" select="substring-before($affected_list_sta, ' ')"/>
    <xsl:variable name="remaining_sta" select="substring-after($affected_list_sta, ' ')"/>
	<xsl:call-template name="aff_station_with_switching">
		<xsl:with-param name="affected" select="$first_sta"/>
		<xsl:with-param name="remaining" select="$remaining_sta"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected HV customers' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_cust" select="e_d_l_affected/customer"/>
	<xsl:variable name="affected_list_cust" select="substring-after($pre_affected_list_cust, ' ')"/>
	<xsl:variable name="first_cust" select="substring-before($affected_list_cust, ' ')"/>
    <xsl:variable name="remaining_cust" select="substring-after($affected_list_cust, ' ')"/>
	<xsl:call-template name="aff_customer_with_switching">
		<xsl:with-param name="affected" select="$first_cust"/>
		<xsl:with-param name="remaining" select="$remaining_cust"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
  	<!--'affected feeders' with their 'switching orders'-->
	<xsl:variable name="pre_affected_list_fd" select="e_d_l_affected/feeder"/>
	<xsl:variable name="affected_list_fd" select="substring-after($pre_affected_list_fd, ' ')"/>
	<xsl:variable name="first_fd" select="substring-before($affected_list_fd, ' ')"/>
    <xsl:variable name="remaining_fd" select="substring-after($affected_list_fd, ' ')"/>
	<xsl:call-template name="aff_feeder_with_switching">
		<xsl:with-param name="affected" select="$first_fd"/>
		<xsl:with-param name="remaining" select="$remaining_fd"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>

<!--e_ev_other		(9: Other event)-->
<xsl:template match="e_ev_other">
	<xsl:param name="eventdate"/>
	<xsl:param name="eventtime"/>
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="e_d_l_line" select="e_d_l_line"/>
	<xsl:choose><xsl:when test="$e_d_l_line">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
					Transmission line&#160;
					<xsl:for-each select="e_d_l_line/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:when></xsl:choose>
	<xsl:variable name="e_d_l_feeder" select="e_d_l_feeder"/>
	<xsl:choose><xsl:when test="$e_d_l_feeder">
		<table width="100%" border="0">
			<tr bgcolor="#ffffff">
				<td align="center"><FONT face="angsana new" style="font-size: 14pt"><u><b><nobr>
					Feeder&#160;
					<xsl:for-each select="e_d_l_feeder/item">
			    		<xsl:value-of select="."/>
			    		<xsl:choose><xsl:when test="position() != last()">
			    			&#160;
			    		</xsl:when></xsl:choose>
  					</xsl:for-each>
  				</nobr></b></u></FONT></td>
  			</tr>
		</table>
	</xsl:when></xsl:choose>
	<xsl:call-template name="event_information">
		<xsl:with-param name="superior"><xsl:value-of select="$superior"/></xsl:with-param>
		<xsl:with-param name="important"><xsl:value-of select="$important"/></xsl:with-param>
		<xsl:with-param name="informedperson"><xsl:value-of select="$informedperson"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="e_d_l_station"></xsl:call-template>
	<!--'switching order' belonging to stations-->
	<xsl:call-template name="e_d_l_equipment">
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
</xsl:template>


<!--event's information-->
<xsl:template name="event_information">
	<xsl:param name="superior"/>
	<xsl:param name="important"/>
	<xsl:param name="informedperson"/>
	<xsl:variable name="az_informedperson" select="$informedperson"/>
	<xsl:variable name="a_informedperson" select="substring-before($az_informedperson, ';')"/>
	<xsl:variable name="bz_informedperson" select="substring-after($az_informedperson, ';')"/>
	<xsl:variable name="b_informedperson" select="substring-before($bz_informedperson, ';')"/>
	<xsl:variable name="cz_informedperson" select="substring-after($bz_informedperson, ';')"/>
	<xsl:variable name="c_informedperson" select="substring-before($cz_informedperson, ';')"/>
	<xsl:variable name="dz_informedperson" select="substring-after($cz_informedperson, ';')"/>
	<xsl:variable name="d_informedperson" select="substring-before($dz_informedperson, ';')"/>
	<xsl:variable name="ez_informedperson" select="substring-after($dz_informedperson, ';')"/>
	<table border="0">
		<!--1st informed persons-->
        <xsl:choose><xsl:when test="$a_informedperson != ''">
        	<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr>Informed person:&#160;&#160;&#160;</nobr></FONT></td>
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$a_informedperson"/></nobr></FONT></td>
			</tr>
        </xsl:when><xsl:otherwise>
        	<xsl:choose><xsl:when test="$az_informedperson != ''">
        		<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr>Informed person:&#160;&#160;&#160;</nobr></FONT></td>
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$az_informedperson"/></nobr></FONT></td>
				</tr>
        	</xsl:when></xsl:choose>
		</xsl:otherwise></xsl:choose>
		<!--2nd informed persons-->
        <xsl:choose><xsl:when test="$b_informedperson">
        	<tr bgcolor="#ffffff">
				<td></td>
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$b_informedperson"/></nobr></FONT></td>
			</tr>
        </xsl:when><xsl:otherwise>
        	<xsl:choose><xsl:when test="$bz_informedperson">
        		<tr bgcolor="#ffffff">
					<td></td>
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$bz_informedperson"/></nobr></FONT></td>
				</tr>
        	</xsl:when></xsl:choose>
		</xsl:otherwise></xsl:choose>
		<!--3rd informed persons-->
        <xsl:choose><xsl:when test="$c_informedperson">
        	<tr bgcolor="#ffffff">
				<td></td>
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$c_informedperson"/></nobr></FONT></td>
			</tr>
        </xsl:when><xsl:otherwise>
        	<xsl:choose><xsl:when test="$cz_informedperson">
        		<tr bgcolor="#ffffff">
					<td></td>
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$cz_informedperson"/></nobr></FONT></td>
				</tr>
        	</xsl:when></xsl:choose>
		</xsl:otherwise></xsl:choose>
		<!--4th informed persons-->
        <xsl:choose><xsl:when test="$d_informedperson">
        	<tr bgcolor="#ffffff">
				<td></td>
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$d_informedperson"/></nobr></FONT></td>
			</tr>
        </xsl:when><xsl:otherwise>
        	<xsl:choose><xsl:when test="$dz_informedperson">
        		<tr bgcolor="#ffffff">
					<td></td>
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$dz_informedperson"/></nobr></FONT></td>
				</tr>
        	</xsl:when></xsl:choose>
		</xsl:otherwise></xsl:choose>
		<!--5th (all remaining) informed persons-->
        <xsl:choose><xsl:when test="$ez_informedperson">
        	<tr bgcolor="#ffffff">
				<td></td>
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="$ez_informedperson"/></nobr></FONT></td>
			</tr>
        </xsl:when></xsl:choose>
	</table>
	<table border="0">
        <xsl:choose><xsl:when test="$superior='1'">
        	<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr>Report to superior</nobr></FONT></td>
			</tr>
		</xsl:when></xsl:choose>
        <xsl:choose><xsl:when test="$important='1'">
        	<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><nobr>Important event</nobr></FONT></td>
			</tr>
        </xsl:when></xsl:choose>
	</table>
	<BR></BR>
</xsl:template>

<!--stations-->
<xsl:template name="e_d_l_station">
	<table border="0">
  		<xsl:for-each select="e_d_l_station/station">
			<tr bgcolor="#ffffff">
			    <td><FONT face="angsana new" style="font-size: 14pt"><nobr><u><b>
			    	<xsl:choose><xsl:when test="./@th_name != ''">
			    		<xsl:value-of select="./@th_name"/>
			    	</xsl:when><xsl:otherwise>
			    		Station <xsl:value-of select="."/>
			    	</xsl:otherwise></xsl:choose>
			    </b></u>&#160;(<xsl:value-of select="./@status"/>)</nobr></FONT></td>
    		</tr>
  		</xsl:for-each>
  	</table>
</xsl:template>

<!--recloser relay-->
<xsl:template name="rr_relay">
	<xsl:param name="e_d_b_rl_rr"/>
	<xsl:param name="e_d_b_rl_rr_off"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_rr_off='0'">
		<xsl:choose><xsl:when test="$e_d_b_rl_rr='1'">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>RR</nobr></i></FONT></td>
		</xsl:when></xsl:choose>
	</xsl:when><xsl:otherwise>
		<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Off RR</nobr></i></FONT></td>
	</xsl:otherwise></xsl:choose>
</xsl:template>

<!--relay not shown-->
<xsl:template name="relay_not_shown">
	<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>RELAY NOT SHOWN</nobr></i></FONT></td></tr>
</xsl:template>

<!--Bus differential relay-->
<xsl:template name="bus_dif_relay">
	<xsl:variable name="e_d_b_rl_df" select="e_d_b_relais/e_d_b_rl_df"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_df='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
				BusDiff
				<xsl:variable name="e_d_b_rl_df_phase_r" select="e_d_b_relais/e_d_b_rl_df_phase_r"/>
				<xsl:variable name="e_d_b_rl_df_phase_y" select="e_d_b_relais/e_d_b_rl_df_phase_y"/>
				<xsl:variable name="e_d_b_rl_df_phase_b" select="e_d_b_relais/e_d_b_rl_df_phase_b"/>
				<xsl:variable name="summing" select="$e_d_b_rl_df_phase_r + $e_d_b_rl_df_phase_y + $e_d_b_rl_df_phase_b"/>
				<xsl:if test="$summing &gt; 0">
					-
				</xsl:if>
				<xsl:choose><xsl:when test="$e_d_b_rl_df_phase_r='1'">R</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_df_phase_y='1'">Y</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_df_phase_b='1'">B</xsl:when></xsl:choose>
			</nobr></i></FONT></td>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--Transformer differential relay-->
<xsl:template name="transf_dif_relay">
	<xsl:variable name="e_d_b_rl_df" select="e_d_b_relais/e_d_b_rl_df"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_df='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
				TransfDiff
				<xsl:variable name="e_d_b_rl_df_phase_r" select="e_d_b_relais/e_d_b_rl_df_phase_r"/>
				<xsl:variable name="e_d_b_rl_df_phase_y" select="e_d_b_relais/e_d_b_rl_df_phase_y"/>
				<xsl:variable name="e_d_b_rl_df_phase_b" select="e_d_b_relais/e_d_b_rl_df_phase_b"/>
				<xsl:variable name="summing" select="$e_d_b_rl_df_phase_r + $e_d_b_rl_df_phase_y + $e_d_b_rl_df_phase_b"/>
				<xsl:if test="$summing &gt; 0">
					-
				</xsl:if>
				<xsl:choose><xsl:when test="$e_d_b_rl_df_phase_r='1'">R</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_df_phase_y='1'">Y</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_df_phase_b='1'">B</xsl:when></xsl:choose>
			</nobr></i></FONT></td>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--Breaker fail-->
<xsl:template name="breaker_fail">
	<xsl:variable name="e_d_b_rl_lb" select="e_d_b_relais/e_d_b_rl_lb"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_lb='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Breaker fail</nobr></i></FONT></td>
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Status = <xsl:value-of select="e_d_b_relais/e_d_e_rl_lb_prot/@type"/></nobr></i></FONT></td>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--distance relay-->
<xsl:template name="distance_relay">
	<xsl:variable name="e_d_b_rl_dr" select="e_d_b_relais/e_d_b_rl_dr"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_dr='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
				DIST
				<xsl:variable name="e_d_b_rl_dr_phase_r" select="e_d_b_relais/e_d_b_rl_dr_phase_r"/>
				<xsl:variable name="e_d_b_rl_dr_phase_y" select="e_d_b_relais/e_d_b_rl_dr_phase_y"/>
				<xsl:variable name="e_d_b_rl_dr_phase_b" select="e_d_b_relais/e_d_b_rl_dr_phase_b"/>
				<xsl:variable name="e_d_b_rl_dr_phase_g" select="e_d_b_relais/e_d_b_rl_dr_phase_g"/>
					<xsl:variable name="summing" select="$e_d_b_rl_dr_phase_r + $e_d_b_rl_dr_phase_y + $e_d_b_rl_dr_phase_b + $e_d_b_rl_dr_phase_g"/>
				<xsl:if test="$summing &gt; 0">
					-
				</xsl:if>
				<xsl:choose><xsl:when test="$e_d_b_rl_dr_phase_r='1'">R</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_dr_phase_y='1'">Y</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_dr_phase_b='1'">B</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_dr_phase_g='1'">G</xsl:when></xsl:choose>
			</nobr></i></FONT></td>
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
				(Zone = 
				<xsl:variable name="e_d_e_rl_dr_zone" select="e_d_b_relais/e_d_e_rl_dr_zone"/>
				<xsl:choose><xsl:when test="$e_d_e_rl_dr_zone='0'">Not shown</xsl:when>
				<xsl:otherwise><xsl:value-of select="$e_d_e_rl_dr_zone"/></xsl:otherwise></xsl:choose>)
			</nobr></i></FONT></td>
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr><xsl:value-of select="e_d_b_relais/e_d_d_rl_dr_dist"/> km.</nobr></i></FONT></td>
    	</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--overcurrent relay-->
<xsl:template name="oc_relay">
	<xsl:variable name="e_d_b_rl_oc" select="e_d_b_relais/e_d_b_rl_oc"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_oc='1'">
		<xsl:variable name="e_d_b_rl_oc_dir" select="e_d_b_relais/e_d_b_rl_oc_dir"/>
		<xsl:variable name="e_d_b_rl_oc_inst" select="e_d_b_relais/e_d_b_rl_oc_inst"/>
		<xsl:variable name="e_d_b_rl_oc_delay" select="e_d_b_relais/e_d_b_rl_oc_delay"/>
		<xsl:choose><xsl:when test="$e_d_b_rl_oc_inst='1'">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_dir='1'">
						DOC-I
					</xsl:when><xsl:otherwise>
						OC-I
					</xsl:otherwise></xsl:choose>
					<xsl:variable name="e_d_b_rl_oc_phase_r" select="e_d_b_relais/e_d_b_rl_oc_phase_r"/>
					<xsl:variable name="e_d_b_rl_oc_phase_y" select="e_d_b_relais/e_d_b_rl_oc_phase_y"/>
					<xsl:variable name="e_d_b_rl_oc_phase_b" select="e_d_b_relais/e_d_b_rl_oc_phase_b"/>
					<xsl:variable name="summing" select="$e_d_b_rl_oc_phase_r + $e_d_b_rl_oc_phase_y + $e_d_b_rl_oc_phase_b"/>
					<xsl:if test="$summing &gt; 0">
						-
					</xsl:if>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_phase_r='1'">R</xsl:when></xsl:choose>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_phase_y='1'">Y</xsl:when></xsl:choose>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_phase_b='1'">B</xsl:when></xsl:choose>
				</nobr></i></FONT></td>
			</tr>
		</xsl:when></xsl:choose>
		<xsl:choose><xsl:when test="$e_d_b_rl_oc_delay='1'">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_dir='1'">
						DOC-T
					</xsl:when><xsl:otherwise>
						OC-T
					</xsl:otherwise></xsl:choose>
					<xsl:variable name="e_d_b_rl_oc_tphase_r" select="e_d_b_relais/e_d_b_rl_oc_tphase_r"/>
					<xsl:variable name="e_d_b_rl_oc_tphase_y" select="e_d_b_relais/e_d_b_rl_oc_tphase_y"/>
					<xsl:variable name="e_d_b_rl_oc_tphase_b" select="e_d_b_relais/e_d_b_rl_oc_tphase_b"/>
					<xsl:variable name="summing" select="$e_d_b_rl_oc_tphase_r + $e_d_b_rl_oc_tphase_y + $e_d_b_rl_oc_tphase_b"/>
					<xsl:if test="$summing &gt; 0">
						-
					</xsl:if>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_tphase_r='1'">R</xsl:when></xsl:choose>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_tphase_y='1'">Y</xsl:when></xsl:choose>
					<xsl:choose><xsl:when test="$e_d_b_rl_oc_tphase_b='1'">B</xsl:when></xsl:choose>
				</nobr></i></FONT></td>
			</tr>
		</xsl:when></xsl:choose>
		<xsl:choose><xsl:when test="$e_d_b_rl_oc_inst='0'">
			<xsl:choose><xsl:when test="$e_d_b_rl_oc_delay='0'">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
						<xsl:choose><xsl:when test="$e_d_b_rl_oc_dir='1'">
							DOC
						</xsl:when><xsl:otherwise>
							OC
						</xsl:otherwise></xsl:choose>
						<xsl:variable name="e_d_b_rl_oc_phase_r" select="e_d_b_relais/e_d_b_rl_oc_phase_r"/>
						<xsl:variable name="e_d_b_rl_oc_phase_y" select="e_d_b_relais/e_d_b_rl_oc_phase_y"/>
						<xsl:variable name="e_d_b_rl_oc_phase_b" select="e_d_b_relais/e_d_b_rl_oc_phase_b"/>
						<xsl:variable name="summing" select="$e_d_b_rl_oc_phase_r + $e_d_b_rl_oc_phase_y + $e_d_b_rl_oc_phase_b"/>
						<xsl:if test="$summing &gt; 0">
							-
						</xsl:if>
						<xsl:choose><xsl:when test="$e_d_b_rl_oc_phase_r='1'">R</xsl:when></xsl:choose>
						<xsl:choose><xsl:when test="$e_d_b_rl_oc_phase_y='1'">Y</xsl:when></xsl:choose>
						<xsl:choose><xsl:when test="$e_d_b_rl_oc_phase_b='1'">B</xsl:when></xsl:choose>
					</nobr></i></FONT></td>
				</tr>
			</xsl:when></xsl:choose>
		</xsl:when></xsl:choose>
	</xsl:when></xsl:choose>
</xsl:template>

<!--earth fault relay-->
<xsl:template name="ef_relay">
	<xsl:variable name="e_d_b_rl_ef" select="e_d_b_relais/e_d_b_rl_ef"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_ef='1'">
		<xsl:variable name="e_d_b_rl_ef_dir" select="e_d_b_relais/e_d_b_rl_ef_dir"/>
		<xsl:variable name="e_d_b_rl_ef_inst" select="e_d_b_relais/e_d_b_rl_ef_inst"/>
		<xsl:variable name="e_d_b_rl_ef_delay" select="e_d_b_relais/e_d_b_rl_ef_delay"/>
		<xsl:choose><xsl:when test="$e_d_b_rl_ef_inst='1'">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
					<xsl:choose><xsl:when test="$e_d_b_rl_ef_dir='1'">
						DEF-I
					</xsl:when><xsl:otherwise>
						EF-I
					</xsl:otherwise></xsl:choose>
				</nobr></i></FONT></td>
			</tr>
		</xsl:when></xsl:choose>
		<xsl:choose><xsl:when test="$e_d_b_rl_ef_delay='1'">
			<tr bgcolor="#ffffff">
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
					<xsl:choose><xsl:when test="$e_d_b_rl_ef_dir='1'">
						DEF-T
					</xsl:when><xsl:otherwise>
						EF-T
					</xsl:otherwise></xsl:choose>
				</nobr></i></FONT></td>
			</tr>
		</xsl:when></xsl:choose>
		<xsl:choose><xsl:when test="$e_d_b_rl_ef_inst='0'">
			<xsl:choose><xsl:when test="$e_d_b_rl_ef_delay='0'">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
						<xsl:choose><xsl:when test="$e_d_b_rl_ef_dir='1'">
							DEF
						</xsl:when><xsl:otherwise>
							EF
						</xsl:otherwise></xsl:choose>
					</nobr></i></FONT></td>
				</tr>
			</xsl:when></xsl:choose>
		</xsl:when></xsl:choose>
	</xsl:when></xsl:choose>
</xsl:template>

<!--current differential relay-->
<xsl:template name="currdiff_relay">
	<xsl:variable name="e_d_b_rl_cu" select="e_d_b_relais/e_d_b_rl_cu"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_cu='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
				CurrDiff
				<xsl:variable name="e_d_b_rl_cu_phase_r" select="e_d_b_relais/e_d_b_rl_cu_phase_r"/>
				<xsl:variable name="e_d_b_rl_cu_phase_y" select="e_d_b_relais/e_d_b_rl_cu_phase_y"/>
				<xsl:variable name="e_d_b_rl_cu_phase_b" select="e_d_b_relais/e_d_b_rl_cu_phase_b"/>
				<xsl:variable name="summing" select="$e_d_b_rl_cu_phase_r + $e_d_b_rl_cu_phase_y + $e_d_b_rl_cu_phase_b"/>
				<xsl:if test="$summing &gt; 0">
					-
				</xsl:if>
				<xsl:choose><xsl:when test="$e_d_b_rl_cu_phase_r='1'">R</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_cu_phase_y='1'">Y</xsl:when></xsl:choose>
				<xsl:choose><xsl:when test="$e_d_b_rl_cu_phase_b='1'">B</xsl:when></xsl:choose>
			</nobr></i></FONT></td>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--over/under voltage relay-->
<xsl:template name="ouv_relay">
	<xsl:variable name="e_d_b_rl_ou" select="e_d_b_relais/e_d_b_rl_ou"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_ou='1'">
		<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>
			<xsl:value-of select="e_d_b_relais/e_d_e_rl_ou_kind/@type"/> relay
		</nobr></i></FONT></td></tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--buchholz relay-->
<xsl:template name="buchholz">
	<xsl:variable name="e_d_b_rl_bu" select="e_d_b_relais/e_d_b_rl_bu"/>
	<xsl:variable name="e_d_b_rl_bu_lo" select="e_d_b_relais/e_d_b_rl_bu_lo"/>
	<xsl:variable name="e_d_b_rl_bu_tr" select="e_d_b_relais/e_d_b_rl_bu_tr"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_bu='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Buchholz relay</nobr></i></FONT></td>
			<xsl:if test="$e_d_b_rl_bu_lo='1'">
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>On-load tap</nobr></i></FONT></td>
			</xsl:if>
			<xsl:if test="$e_d_b_rl_bu_tr='1'">
				<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Transformer</nobr></i></FONT></td>
			</xsl:if>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--sudden gas-->
<xsl:template name="sudden_gas">
	<xsl:variable name="e_d_b_rl_su" select="e_d_b_relais/e_d_b_rl_su"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_su='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Sudden gas</nobr></i></FONT></td>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--back up-->
<xsl:template name="backup">
	<xsl:variable name="e_d_b_rl_bc" select="e_d_b_relais/e_d_b_rl_bc"/>
	<xsl:choose><xsl:when test="$e_d_b_rl_bc='1'">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Back up</nobr></i></FONT></td>
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>Resupply time</nobr></i></FONT></td>
			<td><FONT face="angsana new" style="font-size: 14pt"><i><nobr>"<xsl:value-of select="e_d_b_relais/e_d_v_rl_bc_dati/@time_loc"/>"</nobr></i></FONT></td>
		</tr>
	</xsl:when></xsl:choose>
</xsl:template>

<!--transmission line-->
<xsl:template match="e_d_l_line">
	<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;&#160;At that time, transmission line
  		<xsl:for-each select="./item">
		 	&#160;<xsl:value-of select="."/>
		</xsl:for-each>
		&#160;energize(s) load at
	</nobr></FONT></td>
</xsl:template>

<!--e_d_l_affected (Affected "station, HV customers, feeder")-->
<xsl:template match="e_d_l_affected">
	<xsl:for-each select="station_tm/object">
		<td><FONT face="angsana new" style="font-size: 14pt">
			<xsl:choose><xsl:when test="./@th_name != ''">
				<xsl:value-of select="./@th_name"/>
			</xsl:when><xsl:otherwise>
				station <xsl:value-of select="."/>
			</xsl:otherwise></xsl:choose>
		</FONT></td>
	</xsl:for-each>
	<xsl:for-each select="station_tr/object">
		<td><FONT face="angsana new" style="font-size: 14pt">
			<xsl:choose><xsl:when test="./@th_name != ''">
				<xsl:value-of select="./@th_name"/>
			</xsl:when><xsl:otherwise>
				station <xsl:value-of select="."/>
			</xsl:otherwise></xsl:choose>
		</FONT></td>
	</xsl:for-each>
	<xsl:for-each select="station/object">
		<td><FONT face="angsana new" style="font-size: 14pt">
			<xsl:choose><xsl:when test="./@th_name != ''">
				<xsl:value-of select="./@th_name"/>
			</xsl:when><xsl:otherwise>
				station <xsl:value-of select="."/>
			</xsl:otherwise></xsl:choose>
		</FONT></td>
	</xsl:for-each>
	<xsl:for-each select="customer/object">
		<td><FONT face="angsana new" style="font-size: 14pt">
			HV customer <xsl:value-of select="."/>
		</FONT></td>
	</xsl:for-each>
	<xsl:for-each select="feeder/object">
		<td><FONT face="angsana new" style="font-size: 14pt">
			feeder <xsl:value-of select="."/>
		</FONT></td>
	</xsl:for-each>
	<td><FONT face="angsana new" style="font-size: 14pt">, leads to</FONT></td>
</xsl:template>

<!--'affected station' and 'switching order' of 'transmission line' event-->
<xsl:template name="aff_station_tm_with_switching">
	<xsl:param name="affected"/>
	<xsl:param name="remaining"/>
	<xsl:param name="eventdate"/>
	<xsl:call-template name="aff_station_tm">
		<xsl:with-param name="affected" select="$affected"/>
	</xsl:call-template>
	<xsl:call-template name="switching_of_affected">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="interr_aff_station_tm">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:if test="$remaining">
		<xsl:variable name="next_first" select="substring-before($remaining, ' ')"/>
    	<xsl:variable name="next_remaining" select="substring-after($remaining, ' ')"/>
		<xsl:call-template name="aff_station_tm_with_switching">
			<xsl:with-param name="affected" select="$next_first"/>
			<xsl:with-param name="remaining" select="$next_remaining"/>
			<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

<!--'affected station' of 'transmission line' event-->
<xsl:template name="aff_station_tm">
	<xsl:param name="affected"/>
  	<xsl:for-each select="e_d_l_affected/station_tm/object">
  		<xsl:variable name="station_tm" select="."/>
  		<xsl:if test="$affected=$station_tm">
  			<table border="0">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><u><b>Affected station
						<xsl:choose><xsl:when test="./@th_name != ''">
							<xsl:value-of select="./@th_name"/>
						</xsl:when><xsl:otherwise>
							station <xsl:value-of select="."/>
						</xsl:otherwise></xsl:choose>
					</b></u></nobr></FONT></td>
				</tr>
			</table>
			<table border="0">
				<xsl:if test="./@details != ''">
					<tr bgcolor="#ffffff">
						<td colspan="2"><FONT face="angsana new" style="font-size: 14pt">
							<nobr>&#160;&#160;&#160;&#160;<xsl:value-of select="./@details"/></nobr>
						</FONT></td>
					</tr>
				</xsl:if>
			</table>
			<table border="0">
				<xsl:if test="./@cto='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;CTO <xsl:value-of select="./@cto_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
				<xsl:if test="./@lcto='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;LCTO <xsl:value-of select="./@lcto_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
				<xsl:if test="./@ltf='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;&#160;LTF <xsl:value-of select="./@ltf_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
				<xsl:if test="./@lto='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;&#160;LTO <xsl:value-of select="./@lto_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
				<xsl:if test="./@xto='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;&#160;<xsl:value-of select="./@xto_other"/>&#160;<xsl:value-of select="./@xto_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--interr. of 'affected station' of 'transmission line' event-->
<xsl:template name="interr_aff_station_tm">
	<xsl:param name="affected"/>
	<xsl:param name="eventdate"/>
  	<xsl:for-each select="e_d_l_affected/station_tm/object">
  		<xsl:variable name="station_tm" select="."/>
  		<xsl:if test="$affected=$station_tm">
  			<xsl:variable name="btime" select="./@btime"/>
  			<xsl:variable name="btime_loc" select="./@btime_loc"/>
			<xsl:variable name="date_btime_loc" select="substring-before($btime_loc, ' ')"/>
			<xsl:variable name="time_btime" select="substring-after($btime, ' ')"/>
			<xsl:variable name="etime" select="./@etime"/>
  			<xsl:variable name="etime_loc" select="./@etime_loc"/>
			<xsl:variable name="date_etime_loc" select="substring-before($etime_loc, ' ')"/>
			<xsl:variable name="time_etime" select="substring-after($etime, ' ')"/>
			<xsl:variable name="dur_hh" select="substring-before(./@duration, ':')"/>
			<xsl:variable name="dur_mm_ss" select="substring-after(./@duration, ':')"/>
			<xsl:variable name="dur_mm" select="substring-before($dur_mm_ss, ':')"/>
			<xsl:variable name="dur_ss" select="substring-after($dur_mm_ss, ':')"/>
  			<table border="0">
				<!--in case of short interuption-->
				<xsl:if test="./@cto='Yes' and ./@cto_sta='successful' and ./@cto_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@cto_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<xsl:if test="./@lcto='Yes' and ./@lcto_sta='successful' and ./@lcto_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@lcto_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<xsl:if test="./@ltf='Yes' and ./@ltf_sta='successful' and ./@ltf_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@ltf_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<xsl:if test="./@lto='Yes' and ./@lto_sta='successful' and ./@lto_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@lto_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<xsl:if test="./@xto='Yes' and ./@xto_sta='successful' and ./@xto_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@xto_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<!--in case of long interruption-->
				<xsl:call-template name="long_interr">
					<xsl:with-param name="btime" select="$btime"/>
					<xsl:with-param name="etime" select="$etime"/>
					<xsl:with-param name="eventdate" select="$eventdate"/>
					<xsl:with-param name="date_btime_loc" select="$date_btime_loc"/>
					<xsl:with-param name="time_btime" select="$time_btime"/>
					<xsl:with-param name="date_etime_loc" select="$date_etime_loc"/>
					<xsl:with-param name="time_etime" select="$time_etime"/>
					<xsl:with-param name="dur_hh" select="$dur_hh"/>
					<xsl:with-param name="dur_mm" select="$dur_mm"/>
					<xsl:with-param name="dur_ss" select="$dur_ss"/>
				</xsl:call-template>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--'affected station' and 'switching order' of 'transformer' event-->
<xsl:template name="aff_station_tr_with_switching">
	<xsl:param name="affected"/>
	<xsl:param name="remaining"/>
	<xsl:param name="eventdate"/>
	<xsl:call-template name="aff_station_tr">
		<xsl:with-param name="affected" select="$affected"/>
	</xsl:call-template>
	<xsl:call-template name="switching_of_affected">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="interr_aff_station_tr">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:if test="$remaining">
		<xsl:variable name="next_first" select="substring-before($remaining, ' ')"/>
    	<xsl:variable name="next_remaining" select="substring-after($remaining, ' ')"/>
		<xsl:call-template name="aff_station_tr_with_switching">
			<xsl:with-param name="affected" select="$next_first"/>
			<xsl:with-param name="remaining" select="$next_remaining"/>
			<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

<!--'affected station' of 'transformer' event-->
<xsl:template name="aff_station_tr">
	<xsl:param name="affected"/>
  	<xsl:for-each select="e_d_l_affected/station_tr/object">
  		<xsl:variable name="station_tr" select="."/>
  		<xsl:if test="$affected=$station_tr">
  			<table border="0">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><u><b>Affected station
						<xsl:choose><xsl:when test="./@th_name != ''">
							<xsl:value-of select="./@th_name"/>
						</xsl:when><xsl:otherwise>
							station <xsl:value-of select="."/>
						</xsl:otherwise></xsl:choose>
					</b></u></nobr></FONT></td>
				</tr>
			</table>
			<table border="0">
				<xsl:if test="./@details != ''">
					<tr bgcolor="#ffffff">
						<td colspan="2"><FONT face="angsana new" style="font-size: 14pt">
							<nobr>&#160;&#160;&#160;&#160;<xsl:value-of select="./@details"/></nobr>
						</FONT></td>
					</tr>
				</xsl:if>
			</table>
			<table border="0">
				<xsl:if test="./@bto='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;&#160;BTO <xsl:value-of select="./@bto_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
				<xsl:if test="./@xto='Yes'">
					<tr bgcolor="#ffffff">
						<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
							&#160;&#160;&#160;&#160;<xsl:value-of select="./@xto_other"/>&#160;<xsl:value-of select="./@xto_sta"/>
						</nobr></FONT></td>
					</tr>
				</xsl:if>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--interr. of 'affected station' of 'transformer' event-->
<xsl:template name="interr_aff_station_tr">
	<xsl:param name="affected"/>
	<xsl:param name="eventdate"/>
  	<xsl:for-each select="e_d_l_affected/station_tr/object">
  		<xsl:variable name="station_tr" select="."/>
  		<xsl:if test="$affected=$station_tr">
  			<xsl:variable name="btime" select="./@btime"/>
  			<xsl:variable name="btime_loc" select="./@btime_loc"/>
			<xsl:variable name="date_btime_loc" select="substring-before($btime_loc, ' ')"/>
			<xsl:variable name="time_btime" select="substring-after($btime, ' ')"/>
			<xsl:variable name="etime" select="./@etime"/>
  			<xsl:variable name="etime_loc" select="./@etime_loc"/>
			<xsl:variable name="date_etime_loc" select="substring-before($etime_loc, ' ')"/>
			<xsl:variable name="time_etime" select="substring-after($etime, ' ')"/>
			<xsl:variable name="dur_hh" select="substring-before(./@duration, ':')"/>
			<xsl:variable name="dur_mm_ss" select="substring-after(./@duration, ':')"/>
			<xsl:variable name="dur_mm" select="substring-before($dur_mm_ss, ':')"/>
			<xsl:variable name="dur_ss" select="substring-after($dur_mm_ss, ':')"/>
  			<table border="0">
				<!--in case of short interuption-->
				<xsl:if test="./@bto='Yes' and ./@bto_sta='successful' and ./@bto_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@bto_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<xsl:if test="./@xto='Yes' and ./@xto_sta='successful' and ./@xto_dur != ''">
					<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><nobr>
						&#160;&#160;&#160;&#160;Affect to supply interruption at
						<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
							<xsl:value-of select="$date_btime_loc"/>&#160;
						</xsl:when></xsl:choose>
						<xsl:value-of select="$time_btime"/>&#160;
						for <xsl:value-of select="./@xto_dur"/> sec.
					</nobr></FONT></td></tr>
				</xsl:if>
				<!--in case of long interruption-->
				<xsl:call-template name="long_interr">
					<xsl:with-param name="btime" select="$btime"/>
					<xsl:with-param name="etime" select="$etime"/>
					<xsl:with-param name="eventdate" select="$eventdate"/>
					<xsl:with-param name="date_btime_loc" select="$date_btime_loc"/>
					<xsl:with-param name="time_btime" select="$time_btime"/>
					<xsl:with-param name="date_etime_loc" select="$date_etime_loc"/>
					<xsl:with-param name="time_etime" select="$time_etime"/>
					<xsl:with-param name="dur_hh" select="$dur_hh"/>
					<xsl:with-param name="dur_mm" select="$dur_mm"/>
					<xsl:with-param name="dur_ss" select="$dur_ss"/>
				</xsl:call-template>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--'affected station' and 'switching order' of 'power system outage' event and 'busbar' event-->
<xsl:template name="aff_station_with_switching">
	<xsl:param name="affected"/>
	<xsl:param name="remaining"/>
	<xsl:param name="eventdate"/>
	<xsl:call-template name="aff_station">
		<xsl:with-param name="affected" select="$affected"/>
	</xsl:call-template>
	<xsl:call-template name="switching_of_affected">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="interr_aff_station">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:if test="$remaining">
		<xsl:variable name="next_first" select="substring-before($remaining, ' ')"/>
    	<xsl:variable name="next_remaining" select="substring-after($remaining, ' ')"/>
		<xsl:call-template name="aff_station_with_switching">
			<xsl:with-param name="affected" select="$next_first"/>
			<xsl:with-param name="remaining" select="$next_remaining"/>
			<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

<!--'affected station' of 'power system outage' event and 'busbar' event-->
<xsl:template name="aff_station">
	<xsl:param name="affected"/>
  	<xsl:for-each select="e_d_l_affected/station/object">
  		<xsl:variable name="station" select="."/>
  		<xsl:if test="$affected=$station">
  			<table border="0">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt"><nobr><u><b>Affected station
						<xsl:choose><xsl:when test="./@th_name != ''">
							<xsl:value-of select="./@th_name"/>
						</xsl:when><xsl:otherwise>
							station <xsl:value-of select="."/>
						</xsl:otherwise></xsl:choose>
					</b></u></nobr></FONT></td>
				</tr>
			</table>
			<table border="0">
				<xsl:if test="./@details != ''">
					<tr bgcolor="#ffffff">
						<td colspan="2"><FONT face="angsana new" style="font-size: 14pt">
							<nobr>&#160;&#160;&#160;&#160;<xsl:value-of select="./@details"/></nobr>
						</FONT></td>
					</tr>
				</xsl:if>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--interr. of 'affected station' of 'power system outage' event and 'busbar' event-->
<xsl:template name="interr_aff_station">
	<xsl:param name="affected"/>
	<xsl:param name="eventdate"/>
  	<xsl:for-each select="e_d_l_affected/station/object">
  		<xsl:variable name="station" select="."/>
  		<xsl:if test="$affected=$station">
  			<xsl:variable name="btime" select="./@btime"/>
  			<xsl:variable name="btime_loc" select="./@btime_loc"/>
			<xsl:variable name="date_btime_loc" select="substring-before($btime_loc, ' ')"/>
			<xsl:variable name="time_btime" select="substring-after($btime, ' ')"/>
			<xsl:variable name="etime" select="./@etime"/>
  			<xsl:variable name="etime_loc" select="./@etime_loc"/>
			<xsl:variable name="date_etime_loc" select="substring-before($etime_loc, ' ')"/>
			<xsl:variable name="time_etime" select="substring-after($etime, ' ')"/>
			<xsl:variable name="dur_hh" select="substring-before(./@duration, ':')"/>
			<xsl:variable name="dur_mm_ss" select="substring-after(./@duration, ':')"/>
			<xsl:variable name="dur_mm" select="substring-before($dur_mm_ss, ':')"/>
			<xsl:variable name="dur_ss" select="substring-after($dur_mm_ss, ':')"/>
  			<table border="0">
				<!--in case of long interruption-->
				<xsl:call-template name="long_interr">
					<xsl:with-param name="btime" select="$btime"/>
					<xsl:with-param name="etime" select="$etime"/>
					<xsl:with-param name="eventdate" select="$eventdate"/>
					<xsl:with-param name="date_btime_loc" select="$date_btime_loc"/>
					<xsl:with-param name="time_btime" select="$time_btime"/>
					<xsl:with-param name="date_etime_loc" select="$date_etime_loc"/>
					<xsl:with-param name="time_etime" select="$time_etime"/>
					<xsl:with-param name="dur_hh" select="$dur_hh"/>
					<xsl:with-param name="dur_mm" select="$dur_mm"/>
					<xsl:with-param name="dur_ss" select="$dur_ss"/>
				</xsl:call-template>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--'affected customer' and 'switching order'-->
<xsl:template name="aff_customer_with_switching">
	<xsl:param name="affected"/>
	<xsl:param name="remaining"/>
	<xsl:param name="eventdate"/>
	<xsl:call-template name="aff_customer">
		<xsl:with-param name="affected" select="$affected"/>
	</xsl:call-template>
	<xsl:call-template name="switching_of_affected">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="interr_aff_customer">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:if test="$remaining">
		<xsl:variable name="next_first" select="substring-before($remaining, ' ')"/>
    	<xsl:variable name="next_remaining" select="substring-after($remaining, ' ')"/>
		<xsl:call-template name="aff_customer_with_switching">
			<xsl:with-param name="affected" select="$next_first"/>
			<xsl:with-param name="remaining" select="$next_remaining"/>
			<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

<!--'affected customer'-->
<xsl:template name="aff_customer">
	<xsl:param name="affected"/>
  	<xsl:for-each select="e_d_l_affected/customer/object">
  		<xsl:variable name="customer" select="."/>
  		<xsl:if test="$affected=$customer">
  			<table border="0">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt">
						<nobr><u><b>Affected HV customer <xsl:value-of select="$customer"/></b></u></nobr>
					</FONT></td>
				</tr>
			</table>
			<table border="0">
				<xsl:if test="./@details != ''">
					<tr bgcolor="#ffffff">
						<td colspan="2"><FONT face="angsana new" style="font-size: 14pt">
							<nobr>&#160;&#160;&#160;&#160;<xsl:value-of select="./@details"/></nobr>
						</FONT></td>
					</tr>
				</xsl:if>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--interr. of 'affected customer'-->
<xsl:template name="interr_aff_customer">
	<xsl:param name="affected"/>
	<xsl:param name="eventdate"/>
  	<xsl:for-each select="e_d_l_affected/customer/object">
  		<xsl:variable name="customer" select="."/>
  		<xsl:if test="$affected=$customer">
  			<xsl:variable name="btime" select="./@btime"/>
  			<xsl:variable name="btime_loc" select="./@btime_loc"/>
			<xsl:variable name="date_btime_loc" select="substring-before($btime_loc, ' ')"/>
			<xsl:variable name="time_btime" select="substring-after($btime, ' ')"/>
			<xsl:variable name="etime" select="./@etime"/>
  			<xsl:variable name="etime_loc" select="./@etime_loc"/>
			<xsl:variable name="date_etime_loc" select="substring-before($etime_loc, ' ')"/>
			<xsl:variable name="time_etime" select="substring-after($etime, ' ')"/>
			<xsl:variable name="dur_hh" select="substring-before(./@duration, ':')"/>
			<xsl:variable name="dur_mm_ss" select="substring-after(./@duration, ':')"/>
			<xsl:variable name="dur_mm" select="substring-before($dur_mm_ss, ':')"/>
			<xsl:variable name="dur_ss" select="substring-after($dur_mm_ss, ':')"/>
  			<table border="0">
				<!--in case of long interruption-->
				<xsl:call-template name="long_interr">
					<xsl:with-param name="btime" select="$btime"/>
					<xsl:with-param name="etime" select="$etime"/>
					<xsl:with-param name="eventdate" select="$eventdate"/>
					<xsl:with-param name="date_btime_loc" select="$date_btime_loc"/>
					<xsl:with-param name="time_btime" select="$time_btime"/>
					<xsl:with-param name="date_etime_loc" select="$date_etime_loc"/>
					<xsl:with-param name="time_etime" select="$time_etime"/>
					<xsl:with-param name="dur_hh" select="$dur_hh"/>
					<xsl:with-param name="dur_mm" select="$dur_mm"/>
					<xsl:with-param name="dur_ss" select="$dur_ss"/>
				</xsl:call-template>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--'affected feeder' and 'switching order'-->
<xsl:template name="aff_feeder_with_switching">
	<xsl:param name="affected"/>
	<xsl:param name="remaining"/>
	<xsl:param name="eventdate"/>
	<xsl:call-template name="aff_feeder">
		<xsl:with-param name="affected" select="$affected"/>
	</xsl:call-template>
	<xsl:call-template name="switching_of_affected">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:call-template name="interr_aff_feeder">
		<xsl:with-param name="affected" select="$affected"/>
		<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
	</xsl:call-template>
	<xsl:if test="$remaining">
		<xsl:variable name="next_first" select="substring-before($remaining, ' ')"/>
    	<xsl:variable name="next_remaining" select="substring-after($remaining, ' ')"/>
		<xsl:call-template name="aff_feeder_with_switching">
			<xsl:with-param name="affected" select="$next_first"/>
			<xsl:with-param name="remaining" select="$next_remaining"/>
			<xsl:with-param name="eventdate"><xsl:value-of select="$eventdate"/></xsl:with-param>
		</xsl:call-template>
	</xsl:if>
</xsl:template>

<!--'affected feeder'-->
<xsl:template name="aff_feeder">
	<xsl:param name="affected"/>
  	<xsl:for-each select="e_d_l_affected/feeder/object">
  		<xsl:variable name="feeder" select="."/>
  		<xsl:if test="$affected=$feeder">
  			<table border="0">
				<tr bgcolor="#ffffff">
					<td><FONT face="angsana new" style="font-size: 14pt">
						<nobr><u><b>Affected feeder <xsl:value-of select="$feeder"/></b></u></nobr>
					</FONT></td>
				</tr>
			</table>
			<table border="0">
				<xsl:if test="./@details != ''">
					<tr bgcolor="#ffffff">
						<td colspan="2"><FONT face="angsana new" style="font-size: 14pt">
							<nobr>&#160;&#160;&#160;&#160;<xsl:value-of select="./@details"/></nobr>
						</FONT></td>
					</tr>
				</xsl:if>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--interr. of 'affected feeder'-->
<xsl:template name="interr_aff_feeder">
	<xsl:param name="affected"/>
	<xsl:param name="eventdate"/>
  	<xsl:for-each select="e_d_l_affected/feeder/object">
  		<xsl:variable name="feeder" select="."/>
  		<xsl:if test="$affected=$feeder">
  			<xsl:variable name="btime" select="./@btime"/>
  			<xsl:variable name="btime_loc" select="./@btime_loc"/>
			<xsl:variable name="date_btime_loc" select="substring-before($btime_loc, ' ')"/>
			<xsl:variable name="time_btime" select="substring-after($btime, ' ')"/>
			<xsl:variable name="etime" select="./@etime"/>
  			<xsl:variable name="etime_loc" select="./@etime_loc"/>
			<xsl:variable name="date_etime_loc" select="substring-before($etime_loc, ' ')"/>
			<xsl:variable name="time_etime" select="substring-after($etime, ' ')"/>
			<xsl:variable name="dur_hh" select="substring-before(./@duration, ':')"/>
			<xsl:variable name="dur_mm_ss" select="substring-after(./@duration, ':')"/>
			<xsl:variable name="dur_mm" select="substring-before($dur_mm_ss, ':')"/>
			<xsl:variable name="dur_ss" select="substring-after($dur_mm_ss, ':')"/>
  			<table border="0">
				<!--in case of long interruption-->
				<xsl:call-template name="long_interr">
					<xsl:with-param name="btime" select="$btime"/>
					<xsl:with-param name="etime" select="$etime"/>
					<xsl:with-param name="eventdate" select="$eventdate"/>
					<xsl:with-param name="date_btime_loc" select="$date_btime_loc"/>
					<xsl:with-param name="time_btime" select="$time_btime"/>
					<xsl:with-param name="date_etime_loc" select="$date_etime_loc"/>
					<xsl:with-param name="time_etime" select="$time_etime"/>
					<xsl:with-param name="dur_hh" select="$dur_hh"/>
					<xsl:with-param name="dur_mm" select="$dur_mm"/>
					<xsl:with-param name="dur_ss" select="$dur_ss"/>
				</xsl:call-template>
    		</table>
    	</xsl:if>
  	</xsl:for-each>
</xsl:template>

<!--long interruption-->
<xsl:template name="long_interr">
	<xsl:param name="btime"/>
	<xsl:param name="etime"/>
	<xsl:param name="eventdate"/>
	<xsl:param name="date_btime_loc"/>
	<xsl:param name="time_btime"/>
	<xsl:param name="date_etime_loc"/>
	<xsl:param name="time_etime"/>
	<xsl:param name="dur_hh"/>
	<xsl:param name="dur_mm"/>
	<xsl:param name="dur_ss"/>
	<xsl:if test="$etime != $btime">
		<tr bgcolor="#ffffff">
			<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
				&#160;&#160;&#160;&#160;Affect to supply interruption at
				<xsl:choose><xsl:when test="$date_btime_loc != $eventdate">
					<xsl:value-of select="$date_btime_loc"/>&#160;
				</xsl:when></xsl:choose>
				<xsl:value-of select="$time_btime"/>
				-
				<xsl:choose><xsl:when test="$date_etime_loc != $eventdate">
					<xsl:value-of select="$date_etime_loc"/>&#160;
				</xsl:when></xsl:choose>
				<xsl:value-of select="$time_etime"/>
				&#160;&#160;long
				<xsl:if test="$dur_hh != 0">
					<xsl:choose><xsl:when test="starts-with($dur_hh,'0')">
						<xsl:value-of select="substring-after($dur_hh,'0')"/>
					</xsl:when><xsl:otherwise>
						<xsl:value-of select="$dur_hh"/>
					</xsl:otherwise></xsl:choose>
					hr.
				</xsl:if>
				<xsl:if test="$dur_mm != '00'">
					<xsl:choose><xsl:when test="starts-with($dur_mm,'0')">
						<xsl:value-of select="substring-after($dur_mm,'0')"/>
					</xsl:when><xsl:otherwise>
						<xsl:value-of select="$dur_mm"/>
					</xsl:otherwise></xsl:choose>
					min.
				</xsl:if>
				<xsl:if test="$dur_ss != '00'">
					<xsl:choose><xsl:when test="starts-with($dur_ss,'0')">
						<xsl:value-of select="substring-after($dur_ss,'0')"/>
					</xsl:when><xsl:otherwise>
						<xsl:value-of select="$dur_ss"/>
					</xsl:otherwise></xsl:choose>
					sec.
				</xsl:if>
			</nobr></FONT></td>
    	</tr>
    </xsl:if>
</xsl:template>

<!--'switching order' for station-->
<xsl:template name="e_d_l_equipment">
	<xsl:param name="eventdate"/>
	<table border="0">
  		<xsl:for-each select="e_d_l_equipment/equipment">
  			<xsl:variable name="aftype" select="./@aftype"/>
  			<xsl:variable name="time" select="./@time"/>
			<xsl:variable name="time_loc" select="./@time_loc"/>
			<xsl:variable name="date_time_loc" select="substring-before($time_loc, ' ')"/>
			<xsl:variable name="time_time" select="substring-after($time, ' ')"/>
			<xsl:variable name="status" select="./@status"/>
			<xsl:variable name="remark" select="./@remark"/>
			<xsl:variable name="remark_before" select="substring-before($remark, ' ')"/>
			<xsl:variable name="remark_after" select="substring-after($remark, ' ')"/>
			<xsl:variable name="eq_type" select="./@type"/>
  			<xsl:choose><xsl:when test="$aftype='0'">
				<tr bgcolor="#ffffff">
					<xsl:choose><xsl:when test="$eq_type='-'">
						<xsl:choose><xsl:when test="$remark_before='>'">
							<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
								&#160;&#160;&#160;<xsl:value-of select="$remark_after"/>
							</nobr></FONT></td>
						</xsl:when><xsl:otherwise>
							<td colspan="4"><FONT face="angsana new" style="font-size: 14pt"><nobr>
								&#160;&#160;&#160;&#160;<xsl:value-of select="$remark"/>
							</nobr></FONT></td>
						</xsl:otherwise></xsl:choose>
					</xsl:when><xsl:otherwise>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;
							<xsl:choose><xsl:when test="$date_time_loc != $eventdate">
								<xsl:value-of select="$date_time_loc"/>&#160;
							</xsl:when></xsl:choose>
							<xsl:value-of select="$time_time"/>
						</nobr></FONT></td>
      					<xsl:choose><xsl:when test="$status='Open'">
      						<xsl:choose><xsl:when test="$remark_before='ตก'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ตก</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:when test="$remark_before='ไม่ตก'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ไม่ตก</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
							</xsl:when><xsl:when test="$remark_before='ตกสับติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ตกสับติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:otherwise>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;Open</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      						</xsl:otherwise></xsl:choose>
      					</xsl:when><xsl:when test="$status='Close'">
      						<xsl:choose><xsl:when test="$remark_before='สับติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สับติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:when test="$remark_before='สับไม่ติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สับไม่ติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
							</xsl:when><xsl:otherwise>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;Close</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      						</xsl:otherwise></xsl:choose>
 						</xsl:when><xsl:otherwise>
 							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$status"/></nobr></FONT></td>
      						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      					</xsl:otherwise></xsl:choose>
      				</xsl:otherwise></xsl:choose>
    			</tr>
			</xsl:when><xsl:when test="$aftype='99'">
				<tr bgcolor="#ffffff">
					<xsl:choose><xsl:when test="$eq_type='-'">
						<xsl:choose><xsl:when test="$remark_before='>'">
							<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
								&#160;&#160;&#160;<xsl:value-of select="$remark_after"/>
							</nobr></FONT></td>
						</xsl:when><xsl:otherwise>
							<td colspan="4"><FONT face="angsana new" style="font-size: 14pt"><nobr>
								&#160;&#160;&#160;&#160;<xsl:value-of select="$remark"/>
							</nobr></FONT></td>
						</xsl:otherwise></xsl:choose>
					</xsl:when><xsl:otherwise>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;
							<xsl:choose><xsl:when test="$date_time_loc != $eventdate">
								<xsl:value-of select="$date_time_loc"/>&#160;
							</xsl:when></xsl:choose>
							<xsl:value-of select="$time_time"/>
						</nobr></FONT></td>
      					<xsl:choose><xsl:when test="$status='Open'">
      						<xsl:choose><xsl:when test="$remark_before='ตก'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ตก</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:when test="$remark_before='ไม่ตก'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ไม่ตก</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
							</xsl:when><xsl:when test="$remark_before='ตกสับติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ตกสับติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:otherwise>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;Open</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      						</xsl:otherwise></xsl:choose>
      					</xsl:when><xsl:when test="$status='Close'">
      						<xsl:choose><xsl:when test="$remark_before='สับติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สับติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:when test="$remark_before='สับไม่ติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สับไม่ติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
							</xsl:when><xsl:otherwise>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;Close</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      						</xsl:otherwise></xsl:choose>
 						</xsl:when><xsl:otherwise>
 							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$status"/></nobr></FONT></td>
      						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      					</xsl:otherwise></xsl:choose>
      				</xsl:otherwise></xsl:choose>
    			</tr>
			</xsl:when></xsl:choose>
  		</xsl:for-each>
	</table>
</xsl:template>

<!--'switching order' for affected-->
<xsl:template name="switching_of_affected">
	<xsl:param name="affected"/>
	<xsl:param name="eventdate"/>
	<table border="0">
  		<xsl:for-each select="e_d_l_equipment/equipment">
  			<xsl:variable name="affected_equipment" select="./@affected"/>
  			<xsl:variable name="time" select="./@time"/>
			<xsl:variable name="time_loc" select="./@time_loc"/>
			<xsl:variable name="date_time_loc" select="substring-before($time_loc, ' ')"/>
			<xsl:variable name="time_time" select="substring-after($time, ' ')"/>
			<xsl:variable name="status" select="./@status"/>
			<xsl:variable name="remark" select="./@remark"/>
			<xsl:variable name="remark_before" select="substring-before($remark, ' ')"/>
			<xsl:variable name="remark_after" select="substring-after($remark, ' ')"/>
			<xsl:variable name="eq_type" select="./@type"/>
  			<xsl:choose><xsl:when test="$affected=$affected_equipment">
				<tr bgcolor="#ffffff">
					<xsl:choose><xsl:when test="$eq_type='-'">
						<xsl:choose><xsl:when test="$remark_before='>'">
							<td>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;</td>
							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>
								&#160;&#160;&#160;<xsl:value-of select="$remark_after"/>
							</nobr></FONT></td>
						</xsl:when><xsl:otherwise>
							<td colspan="4"><FONT face="angsana new" style="font-size: 14pt"><nobr>
								&#160;&#160;&#160;&#160;<xsl:value-of select="$remark"/>
							</nobr></FONT></td>
						</xsl:otherwise></xsl:choose>
					</xsl:when><xsl:otherwise>
						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;
							<xsl:choose><xsl:when test="$date_time_loc != $eventdate">
								<xsl:value-of select="$date_time_loc"/>&#160;
							</xsl:when></xsl:choose>
							<xsl:value-of select="$time_time"/>
						</nobr></FONT></td>
      					<xsl:choose><xsl:when test="$status='Open'">
      						<xsl:choose><xsl:when test="$remark_before='ตก'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ตก</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:when test="$remark_before='ไม่ตก'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ไม่ตก</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
							</xsl:when><xsl:when test="$remark_before='ตกสับติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สวิตช์ตกสับติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:otherwise>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;Open</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      						</xsl:otherwise></xsl:choose>
      					</xsl:when><xsl:when test="$status='Close'">
      						<xsl:choose><xsl:when test="$remark_before='สับติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สับติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
      						</xsl:when><xsl:when test="$remark_before='สับไม่ติด'">
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;สับไม่ติด</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark_after"/></nobr></FONT></td>
							</xsl:when><xsl:otherwise>
      							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;Close</nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      								<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      						</xsl:otherwise></xsl:choose>
 						</xsl:when><xsl:otherwise>
 							<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$status"/></nobr></FONT></td>
      						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="./@component"/></nobr></FONT></td>
      						<td><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;<xsl:value-of select="$remark"/></nobr></FONT></td>
      					</xsl:otherwise></xsl:choose>
      				</xsl:otherwise></xsl:choose>
    			</tr>
			</xsl:when></xsl:choose>
  		</xsl:for-each>
	</table>
</xsl:template>

<xsl:template match="si_list">
	<BR></BR>
	<FONT face="angsana new" style="font-size: 14pt"><nobr><u><b>Supply Interruptions</b></u></nobr></FONT>
	<table width="100%" border="0" bordercolor="black" cellpadding="0%">
		<tr bgcolor="#ffffff">
			<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;&#160;Begin</nobr></FONT></td>
			<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>End</nobr></FONT></td>
			<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>Interrupted active power</nobr></FONT></td>
			<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>EU-transformer</nobr></FONT></td>
			<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>Station</nobr></FONT></td>
		</tr>
		<xsl:for-each select="si">
			<tr bgcolor="#ffffff">
					<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr>&#160;&#160;&#160;&#160;<xsl:value-of select="e_d_v_vubtime"/></nobr></FONT></td>
					<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="e_d_v_vuetime"/></nobr></FONT></td>
					<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="e_d_d_vupower"/></nobr></FONT></td>
					<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="e_d_b_vubtrafo"/></nobr></FONT></td>
					<td align="center"><FONT face="angsana new" style="font-size: 14pt"><nobr><xsl:value-of select="e_d_l_vustation"/></nobr></FONT></td>
			</tr>
		</xsl:for-each>
	</table>
</xsl:template>

<xsl:template name="test_txt_filetypes">
    <xsl:param name="list"/>
    <xsl:param name="ist_typ"/>
    <xsl:param name="cur_name"/>
    <xsl:param name="cur_desc"/>
    <xsl:variable name="newlist" select="concat(normalize-space($list), ' ')"/>
    <xsl:variable name="first" select="substring-before($newlist, ' ')"/>
    <xsl:variable name="remaining" select="substring-after($newlist, ' ')"/>
    <xsl:variable name="vreftyp" select="$first"/>

    <xsl:choose>
        <xsl:when test="$vreftyp=$ist_typ">
            <!-- txt Filetype gefunden -->
            <xsl:call-template name="mtext"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:choose>
                <xsl:when test="$remaining">
                    <!-- weiteres Listenelement vorhanden, also weitersuchen -->
                    <xsl:call-template name="test_txt_filetypes">
                        <xsl:with-param name="list" select="$remaining"/>
                        <xsl:with-param name="ist_typ" select="$ist_typ"/>
                        <xsl:with-param name="cur_name" select="$cur_name"/>
                        <xsl:with-param name="cur_desc" select="$cur_desc"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <!-- Dateityp nicht in der Liste   img_list -->
                    <xsl:call-template name="test_img_filetypes">
                        <xsl:with-param name="list"><xsl:value-of select="$img_list"/></xsl:with-param>
                        <xsl:with-param name="ist_typ" select="$ist_typ"/>
                        <xsl:with-param name="cur_name" select="$cur_name"/>
                        <xsl:with-param name="cur_desc" select="$cur_desc"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="test_img_filetypes">
    <xsl:param name="list"/>
    <xsl:param name="ist_typ"/>
    <xsl:param name="cur_name"/>
    <xsl:param name="cur_desc"/>
    <xsl:variable name="newlist" select="concat(normalize-space($list), ' ')"/>
    <xsl:variable name="first" select="substring-before($newlist, ' ')"/>
    <xsl:variable name="remaining" select="substring-after($newlist, ' ')"/>
    <xsl:variable name="vreftyp" select="$first"/>

    <xsl:choose>
        <xsl:when test="$vreftyp=$ist_typ">
            <!-- IMG Filetype gefunden -->
            <xsl:call-template name="mimage"/>
        </xsl:when>
        <xsl:otherwise>
            <xsl:choose>
                <xsl:when test="$remaining">
                    <!-- weiteres Listenelement vorhanden, also weitersuchen -->
                    <xsl:call-template name="test_img_filetypes">
                        <xsl:with-param name="list" select="$remaining"/>
                        <xsl:with-param name="ist_typ" select="$ist_typ"/>
                        <xsl:with-param name="cur_name" select="$cur_name"/>
                        <xsl:with-param name="cur_desc" select="$cur_desc"/>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <!-- Dateityp nicht in der Liste   img_list -->
                    <tr bgcolor="#ffffff">
                    		<td><FONT face="angsana new" style="font-size: 14pt"><a><xsl:attribute name="href">./.<xsl:value-of select="$cur_name"/></xsl:attribute><xsl:value-of select="$cur_desc"/></a></FONT></td>
                    </tr>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>

<xsl:template name="mimage">
        <tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><u>Image</u> "<xsl:value-of select="./@desc"/>"</FONT></td></tr>
        <tr bgcolor="#ffffff"><td>&#160;&#160;
        	<xsl:element name="IMG">
            	<xsl:attribute name="SRC">./.<xsl:value-of select="."/></xsl:attribute>
        	</xsl:element>
        </td></tr>
</xsl:template>

<xsl:template name="mtext">
        <tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt"><u>Text</u> "<xsl:value-of select="./@desc"/>"</FONT></td></tr>
        <tr bgcolor="#ffffff"><td>
        	<table border="0">
            	<xsl:for-each select="./item">
	            		<tr bgcolor="#ffffff"><td><FONT face="angsana new" style="font-size: 14pt">&#160;&#160;&#160;<xsl:value-of select="."/></FONT></td></tr>
            	</xsl:for-each>
        	</table>
        </td></tr>
</xsl:template>

<!--display text in tab 'details' (for W/P event only)-->
<xsl:template name="wp_details">
    <xsl:param name="e_d_x_comment"/>
	<xsl:choose><xsl:when test="$e_d_x_comment">
		<table border="0">
			<tr bgcolor="#ffffff"><td>
				<FONT face="angsana new" style="font-size: 14pt"><xsl:value-of select="$e_d_x_comment"/></FONT>
			</td></tr>
		</table>
	</xsl:when></xsl:choose>
</xsl:template>

</xsl:stylesheet>