<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 
	version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"  
	xmlns:witsml="http://www.witsml.org/schemas/regulatory/130d">
<xsl:output method="html" />
<xsl:template match="/">

<!-- This template assumes that: 
	1) There is only one wellbore per well. 
	2) A wellDatum is the default for all elevations and depths and it is referenced to a sea level wellDatum.
	3) There is only one regulatoryDocument with agencyForm='CalWIMS'
-->

<!-- Changes: 
	1) Map "Estimated Total Depth" to mdPlanned instead of tvdPlanned.
-->

	<xsl:for-each select="witsml:WITSMLRegulatory/witsml:wellSet/witsml:well">
		<xsl:for-each select="witsml:regulatoryDocumentSet/witsml:regulatoryDocument">
			<xsl:if test="witsml:agencyForm = 'CalWIMS'">
				<xsl:choose>
					<xsl:when test="witsml:type='drill new well'">
						<xsl:call-template name="newWell"/>
					</xsl:when>
					<xsl:when test="witsml:type='redrill'">
						<xsl:call-template name="redrill"/>
					</xsl:when>
					<xsl:when test="witsml:type='Rework Well'">
						<xsl:call-template name="rework"/>
					</xsl:when>
					<xsl:when test="witsml:type='Abandon Well'">
						<xsl:call-template name="abandon"/>
					</xsl:when>
				</xsl:choose>
			</xsl:if>
		</xsl:for-each>
	</xsl:for-each>
	</xsl:template>

<!--   =======================NOTICES====================================   -->

	<xsl:template name="abandon">
		<html>
		<head>
			<title>
				WITSML Regulatory - CalWIMS Abandonment Notice
			</title>
			<link rel='stylesheet' href='../stylesheets/witsml.css' type='text/css' />
		</head>
		<body>
		<H1>CalWIMS</H1>
		<table border="0" width="100%">
			<tr>
				<td align="left"><b>Notice Of Intention To Abandon</b></td>
				<td align="center"><b><xsl:value-of select="../../witsml:generalInformation/witsml:operator"/></b></td>
				<td align="right"><b>Date:<xsl:value-of select="witsml:submittalDate"/></b></td>
			</tr>
			<tr>
				<td colspan="3"><small>In compliance with Section 3203, Public resources Code, notice is hereby given 
				that it is our intention to commence drilling the following well.</small></td>
			</tr>
		</table>
		<P> </P>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="CEQA"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="confidential"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellLocation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="surfaceLease"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="mineralRights"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellProperties">
			<xsl:with-param name="formType">redrill</xsl:with-param>
		</xsl:apply-templates>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="criticalWell"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellElevation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="usageType"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="directional"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="proposedBorehole"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingString"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingCement"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="perforation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="plug"/>
		<!--
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="latest"/>
		-->
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="dryHole"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="show"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="stratigraphic"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="contact"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="LeadAgency"/>
		</body>
		</html>
	</xsl:template>

	<xsl:template name="rework">
		<html>
		<head>
			<title>
				WITSML Regulatory - CalWIMS Rework Notice
			</title>
			<link rel='stylesheet' href='../stylesheets/witsml.css' type='text/css' />
		</head>
		<body>
		<H1>CalWIMS</H1>
		<table border="0" width="100%">
			<tr>
				<td align="left"><b>Notice Of Intention To Rework</b></td>
				<td align="center"><b><xsl:value-of select="../../witsml:generalInformation/witsml:operator"/></b></td>
				<td align="right"><b>Date:<xsl:value-of select="witsml:submittalDate"/></b></td>
			</tr>
			<tr>
				<td colspan="3"><small>In compliance with Section 3203, Public resources Code, notice is hereby given 
				that it is our intention to commence drilling the following well.</small></td>
			</tr>
		</table>
		<P> </P>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="CEQA"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="confidential"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellLocation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="surfaceLease"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="mineralRights"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellProperties">
			<xsl:with-param name="formType">redrill</xsl:with-param>
		</xsl:apply-templates>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="criticalWell"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellElevation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="usageType"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="directional"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="proposedBorehole"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingString"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingCement"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="perforation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="plug"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="latest"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="contact"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="LeadAgency"/>
		</body>
		</html>
	</xsl:template>

	<xsl:template name="redrill">
		<html>
		<head>
			<title>
				WITSML Regulatory - CalWIMS Redrill Notice
			</title>
			<link rel='stylesheet' href='../stylesheets/witsml.css' type='text/css' />
		</head>
		<body>
		<H1>CalWIMS</H1>
		<table border="0" width="100%">
			<tr>
				<td align="left"><b>Notice Of Intention To Redrill</b></td>
				<td align="center"><b><xsl:value-of select="../../witsml:generalInformation/witsml:operator"/></b></td>
				<td align="right"><b>Date:<xsl:value-of select="witsml:submittalDate"/></b></td>
			</tr>
			<tr>
				<td colspan="3"><small>In compliance with Section 3203, Public resources Code, notice is hereby given 
				that it is our intention to commence drilling the following well.</small></td>
			</tr>
		</table>
		<P> </P>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="CEQA"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="confidential"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellLocation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="surfaceLease"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="mineralRights"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellProperties">
			<xsl:with-param name="formType">redrill</xsl:with-param>
		</xsl:apply-templates>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="criticalWell"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellElevation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="usageType"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="directional"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="proposedBorehole"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingString"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingCement"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="perforation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="plug"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="latest"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="contact"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="LeadAgency"/>
		</body>
		</html>
	</xsl:template>

	<xsl:template name="newWell">
		<html>
		<head>
			<title>
				WITSML Regulatory - CalWIMS New Well Notice
			</title>
			<link rel='stylesheet' href='../stylesheets/witsml.css' type='text/css' />
		</head>
		<body>
		<H1>CalWIMS</H1>
		<table border="0" width="100%">
			<tr>
				<td align="left"><b>Notice Of Intention To Drill New Well</b></td>
				<td align="center"><b><xsl:value-of select="../../witsml:generalInformation/witsml:operator"/></b></td>
				<td align="right"><b>Date:<xsl:value-of select="witsml:submittalDate"/></b></td>
			</tr>
			<tr>
				<td colspan="3"><small>In compliance with Section 3203, Public resources Code, notice is hereby given 
				that it is our intention to commence drilling the following well.</small></td>
			</tr>
		</table>
		<P> </P>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="CEQA"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="confidential"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellLocation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="surfaceLease"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="mineralRights"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellProperties">
			<xsl:with-param name="newWell">redrill</xsl:with-param>
		</xsl:apply-templates>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="criticalWell"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="wellElevation"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="usageType"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="directional"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="proposedBorehole"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingString"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="casingCement"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="contact"/>
		<xsl:apply-templates select="../../witsml:generalInformation"  mode="LeadAgency"/>
		</body>
		</html>
	</xsl:template>

<!--   =======================NOTICE COMPONENTS====================================   -->

	<xsl:template match="witsml:generalInformation" mode="stratigraphic">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="3" class='tableheader'>WELL STRATIGRAPHIC MARKER</th>
			</tr>
			<tr>
				<th>Name</th>
				<th>Top True Vertical Depth</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:formationMarkerSet/witsml:formationMarker">
				<tr>
					<td>
						<b>
							<xsl:value-of select="witsml:nameFormation"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:tvdLogSample" mode="valueWithUomRef"/>>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="witsml:commonData/witsml:itemState"> <!-- formationMarker -->
									<xsl:value-of select="witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>


	<xsl:template match="witsml:generalInformation" mode="show">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="3" class='tableheader'>OIL AND GAS SHOW</th>
			</tr>
			<tr>
				<th>Top True Vertical Depth</th>
				<th>Bottom True Vertical Depth</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:classifiedIntervalSet/witsml:classifiedInterval">
				<xsl:sort data-type="number" select="witsml:tvdTop"/>
				<xsl:if test="witsml:classification/witsml:namingSystem = 'CalWIMS classsification'">
					<xsl:if test="witsml:classification/witsml:class = 'OilAndGasShow'">
						<tr>
							<td>
								<b>
									<xsl:apply-templates select="witsml:tvdTop" mode="valueWithUomRef"/>
								</b>
							</td>
							<td>
								<b>
									<xsl:apply-templates select="witsml:valueWithUomRef" mode="valueWithUomRef"/>
								</b>
							</td>
							<td>
								<b>
									<xsl:choose>
										<xsl:when test="witsml:itemState"> <!-- classifiedInterval -->
											<xsl:value-of select="witsml:itemState"/>
										</xsl:when>
										<xsl:when test="../../witsml:generalInformation/witsml:itemState"> <!-- wellbore -->
											<xsl:value-of select="../../witsml:generalInformation/witsml:itemState"/>
										</xsl:when>
										<xsl:when test="../../../../witsml:generalInformation/witsml:itemState"> <!-- well -->
											<xsl:value-of select="../../../../witsml:generalInformation/witsml:itemState"/>
										</xsl:when>
										<xsl:otherwise>
											Actual
										</xsl:otherwise>
									</xsl:choose>
								</b>
							</td>
						</tr>
					</xsl:if>
				</xsl:if>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>


	<xsl:template match="witsml:generalInformation" mode="dryHole">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="4" class='tableheader'>WELL DRY HOLE</th>
			</tr>
			<tr>
				<th>True Vertical Depth</th>
				<th>Geologic Age</th>
				<th>Geologic Formation</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="witsml:classification">
				<xsl:if test="witsml:namingSystem = 'CalWIMS classification'">
					<xsl:if test="witsml:class = 'DryHole'">
						<xsl:call-template name="formation"/>
					</xsl:if>
				</xsl:if>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>
	<xsl:template name="formation">
		<xsl:for-each select="../../witsml:wellboreSet/witsml:wellbore/witsml:formationMarkerSet/witsml:formationMarker">
			<xsl:if test="(witsml:mdTopSample + witsml:thicknessApparent) = ../../witsml:generalInformation/witsml:mdCurrent">
				<tr>
					<td>
						<b>
						<xsl:apply-templates select="../../witsml:generalInformation/witsml:tvdCurrent" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:chronostratigraphic"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:nameFormation"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="witsml:itemState"> <!-- formationMarker -->
									<xsl:value-of select="witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../witsml:generalInformation/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../witsml:generalInformation/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../../witsml:generalInformation/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../../witsml:generalInformation/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>


	<xsl:template match="witsml:generalInformation" mode="latest">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="4" class='tableheader'>LATEST PRODUCTION</th>
			</tr>
			<tr>
				<th>Gas Rate</th>
				<th>Oil Rate</th>
				<th>Water Rate</th>
				<th>Latest Production Date</th>
			</tr>
			<tr>
				<td>
					<b>
						<xsl:apply-templates select="witsml:latestProductionInjection/witsml:productionGasRate" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>
					<b>
						<xsl:apply-templates select="witsml:latestProductionInjection/witsml:productionOilRate" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>
					<b>
						<xsl:apply-templates select="witsml:latestProductionInjection/witsml:productionWaterRate" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>
					<b>
						<xsl:value-of select="witsml:latestProductionInjection/witsml:productionDate"/>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="4" class='tableheader'>LATEST INJECTION</th>
			</tr>
			<tr>
				<th>Gas Rate</th>
				<th>Oil Rate</th>
				<th>Water Rate</th>
				<th>Latest Injection Date</th>
			</tr>
			<tr>
				<td>
					<b>
						<xsl:apply-templates select="witsml:latestProductionInjection/witsml:injectionGasRate" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>
					<b>
						<xsl:apply-templates select="witsml:latestProductionInjection/witsml:injectionOilRate" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>
					<b>
						<xsl:apply-templates select="witsml:latestProductionInjection/witsml:injectionWaterRate" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>
					<b>
						<xsl:value-of select="witsml:latestProductionInjection/witsml:injectionDate"/>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="plug">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="6" class='tableheader'>WELL CASING PLUGS</th>
			</tr>
			<tr>
				<th>Top Depth</th>
				<th>Bottom Depth</th>
				<th>Volume</th>
				<th>API Cement Class</th>
				<th>Casing Type Plug</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:casingPlugSummary">
				<xsl:sort data-type="number" select="witsml:mdTop"/>
				<tr>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdTop" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdBottom" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:volume" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:APICementClass"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:plugType"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="witsml:itemState"> <!-- casingPlugSummary -->
									<xsl:value-of select="witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>


	<xsl:template match="witsml:generalInformation" mode="perforation">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="4" class='tableheader'>WELL CASING PERFORATIONS</th>
			</tr>
			<tr>
				<th>Top Depth</th>
				<th>Bottom Depth</th>
				<th>Shot Density</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:perforationIntervalSet/witsml:perforationInterval">
				<xsl:sort data-type="number" select="witsml:mdTop"/>
				<tr>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdTop" mode="valueWithUomRef"/>>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdBottom" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:shotDensity" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="witsml:commonData/witsml:itemState"> <!-- perforationInterval -->
									<xsl:value-of select="witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="LeadAgency">
		<xsl:for-each select="witsml:businessAssociate">
			<xsl:if test="witsml:role/witsml:namingSystem = 'CalWIMS classification'">
				<xsl:if test="witsml:role/witsml:name = 'lead agency'">
					<table border="1" width="90%">
						<tr>
							<th align="left" colspan="4" class='tableheader'>LEAD AGENCY</th>
						</tr>
						<tr>
							<td colspan="4"><small>Information for compliance with the California Environmental Quality Ace of 1970 (C.E.Q.A.).
							If an environmental document has been prepared by the lead agency, please submit a 
							copy of the document with this notice or supply the following information.</small></td>
						</tr>
						<tr>
							<td>Lead Agency Name: 
								<b>
									<xsl:value-of select="witsml:name"/> 
								</b>
							</td>
							<td>Mailing Address Street: 
								<xsl:for-each select="witsml:address">
									<xsl:if test="@kind = 'mailing'">
										<xsl:for-each select="witsml:street">
											<xsl:if test="position() = 1">
												<b><xsl:value-of select="."/></b>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:for-each>
							</td>
						</tr>
						<tr>
							<td>Mailing Address Street 2: 
								<xsl:for-each select="witsml:address">
									<xsl:if test="@kind = 'mailing'">
										<xsl:for-each select="witsml:street">
											<xsl:if test="position() = 2">
												<b><xsl:value-of select="."/></b>
											</xsl:if>
										</xsl:for-each>
									</xsl:if>
								</xsl:for-each>
							</td>
							<td>City: 
								<xsl:for-each select="witsml:address">
									<xsl:if test="@kind = 'mailing'">
										<b><xsl:value-of select="witsml:city"/></b>
									</xsl:if>
								</xsl:for-each>
							</td>
						</tr>
						<tr>
							<td>State: 
								<xsl:for-each select="witsml:address">
									<xsl:if test="@kind = 'mailing'">
										<b><xsl:value-of select="witsml:state"/></b>
									</xsl:if>
								</xsl:for-each>
							</td>
							<td>Zip Code: 
								<xsl:for-each select="witsml:address">
									<xsl:if test="@kind = 'mailing'">
										<b><xsl:value-of select="witsml:postalCode"/></b>
									</xsl:if>
								</xsl:for-each>
							</td>
						</tr>
						<xsl:variable name="contactUID"><xsl:value-of select="witsml:contact/@uidRef"/></xsl:variable>
						<xsl:for-each select="../witsml:businessAssociate">
							<xsl:if test="@uid = $contactUID">
								<tr>
									<td>First Name: 
										<b><xsl:value-of select="witsml:personName/witsml:first"/> </b>
									</td>
									<td>Last Name:  
										<b><xsl:value-of select="witsml:personName/witsml:last"/></b>
									</td>
								</tr>
								<tr>
									<td>Phone#:
										<xsl:for-each select="witsml:phoneNumber">
											<xsl:if test="@type = 'voice'">
												<b><xsl:value-of select="."/></b>
												Ext#:
												<b><xsl:value-of select="@extension"/></b>
											</xsl:if>
										</xsl:for-each>
									</td>
								</tr>
							</xsl:if>
						</xsl:for-each>
					</table>
				</xsl:if>
			</xsl:if>
		</xsl:for-each>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="contact">
		<xsl:for-each select="../witsml:regulatoryDocumentSet/witsml:regulatoryDocument">
			<xsl:if test="witsml:agencyForm ='CalWIMS'">
				<xsl:variable name="submitterlUID"><xsl:value-of select="witsml:submitter/@uidRef"/></xsl:variable>
				<xsl:variable name="submittalDate"><xsl:value-of select="witsml:submittalDate"/></xsl:variable>
				<xsl:for-each select="../../witsml:generalInformation/witsml:businessAssociate">
					<xsl:if test="@uid = $submitterlUID">
						<table border="1" width="90%">
							<tr>
								<th align="left" colspan="4" class='tableheader'>PERSON FILING NOTICE CONTACT INFORMATION</th>
							</tr>
							<tr>
								<td colspan="4"><small>It is understood that if changes to this plan become necessary, 
								we are to notify you immediately. The agent will receive copies of any correspondence 
								(including permits) resulting from this notice. Please add contact information for 
								any other persons you wish to receive copies.</small></td>
							</tr>
							<tr>
								<td>First Name: 
									<b>
										<xsl:value-of select="witsml:personName/witsml:first"/> 
									</b>
								</td>
								<td>Email Address: 
									<b> 
										<xsl:value-of select="witsml:email"/> 
									</b>
								</td>
							</tr>
							<tr>
								<td>Last Name:  
									<b>
										<xsl:value-of select="witsml:personName/witsml:last"/> 
									</b>
								</td>
								<td>Phone#:
									<xsl:for-each select="witsml:phoneNumber">
										<xsl:if test="@type = 'voice'">
											<b><xsl:value-of select="."/></b>
											Ext#:
											<b><xsl:value-of select="@extension"/></b>
										</xsl:if>
									</xsl:for-each>
								</td>
							</tr>
							<tr>
								<td>Mailing Address Street: 
									<xsl:for-each select="witsml:address">
										<xsl:if test="@kind = 'mailing'">
											<xsl:for-each select="witsml:street">
												<xsl:if test="position() = 1">
													<b><xsl:value-of select="."/></b>
												</xsl:if>
											</xsl:for-each>
										</xsl:if>
									</xsl:for-each>
								</td>
								<td>Phone#:
									<xsl:for-each select="witsml:phoneNumber">
										<xsl:if test="@type = 'voice'">
											<b><xsl:value-of select="."/></b>
										</xsl:if>
									</xsl:for-each>
								</td>
							</tr>
							<tr>
								<td>Mailing Address Street 2: 
									<xsl:for-each select="witsml:address">
										<xsl:if test="@kind = 'mailing'">
											<xsl:for-each select="witsml:street">
												<xsl:if test="position() = 2">
													<b><xsl:value-of select="."/></b>
												</xsl:if>
											</xsl:for-each>
										</xsl:if>
									</xsl:for-each>
								</td>
								<td>Contact Preference:
									<xsl:choose>
										<xsl:when test="contains(witsml:contactPreference,' email')">
											<b>email</b>
										</xsl:when>
										<xsl:when test="contains(witsml:contactPreference,' mail')">
											<b>mail</b>
										</xsl:when>
										<xsl:when test="contains(witsml:contactPreference,' fax')">
											<b>fax</b>
										</xsl:when>
									</xsl:choose>
								</td>
							</tr>
							<tr>
								<td>City: 
									<xsl:for-each select="witsml:address">
										<xsl:if test="@kind = 'mailing'">
											<b><xsl:value-of select="witsml:city"/></b>
										</xsl:if>
									</xsl:for-each>
								</td>
								<td>Date Notice Signed: <b>Not Applicable</b>
								</td>
							</tr>
							<tr>
								<td>State: 
									<xsl:for-each select="witsml:address">
										<xsl:if test="@kind = 'mailing'">
											<b><xsl:value-of select="witsml:state"/></b>
										</xsl:if>
									</xsl:for-each>
								</td>
								<td>Notice Submission Date: 
									<b>
										<xsl:value-of select="$submittalDate"/>
									</b>
								</td>
							</tr>
							<tr>
								<td>Zip Code: 
									<xsl:for-each select="witsml:address">
										<xsl:if test="@kind = 'mailing'">
											<b><xsl:value-of select="witsml:postalCode"/></b>
										</xsl:if>
									</xsl:for-each>
								</td>
							</tr>
						</table>
					</xsl:if>
				</xsl:for-each>
			</xsl:if>
		</xsl:for-each>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="casingCement">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="7" class='tableheader'>CASING CEMENT</th>
			</tr>
			<tr>
				<th>Bottom Depth</th>
				<th>Distance above Bottom Depth</th>
				<th>Volume</th>
				<th>API Cement Class</th>
				<th>Cement Device</th>
				<th>Cement Mixture</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:cementSummary">
				<xsl:sort data-type="number" select="witsml:mdTop"/>
				<tr>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdBottom" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdBottom" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:volume" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:APICementClass"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:cementBottomDepthDevice"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:value-of select="witsml:cementMixture"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="witsml:itemState"> <!-- cementSummary -->
									<xsl:value-of select="witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="casingString">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="7" class='tableheader'>WELL CASING STRING</th>
			</tr>
			<tr>
				<th>Type</th>
				<th>Diameter</th>
				<th>Top Depth</th>
				<th>Bottom Depth</th>
				<th>Weight</th>
				<th>Grade</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:wbGeometrySet/witsml:wbGeometry/witsml:wbGeometrySection">
				<xsl:sort data-type="number" select="witsml:mdTop"/>
				<tr>
					<td>
						<b>
							<xsl:value-of select="witsml:typeHoleCasing"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:odSection" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdTop" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdBottom" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:wtPerLen" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:grade" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="../witsml:commonData/witsml:itemState"> <!-- trajectory -->
									<xsl:value-of select="../witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="proposedBorehole">
		<table border="1" width="70%">
			<tr>
				<th align="left" colspan="3" class='tableheader'>WELL BORE</th>
			</tr>
			<tr>
				<th>Hole Diameter</th>
				<th>Well Bore Bottom Depth</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:boreholeIntervalSet/witsml:boreholeInterval">
				<xsl:sort data-type="number" select="witsml:mdTop"/>
				<tr>
					<td>
						<b>
							<xsl:apply-templates select="witsml:holeDiameter" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:apply-templates select="witsml:mdBottom" mode="valueWithUomRef"/>
						</b>
					</td>
					<td>
						<b>
							<xsl:choose>
								<xsl:when test="witsml:commonData/witsml:itemState"> <!-- boreholeInterval -->
									<xsl:value-of select="witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
									<xsl:value-of select="../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:when test="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
									<xsl:value-of select="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
								</xsl:when>
								<xsl:otherwise>
									Actual
								</xsl:otherwise>
							</xsl:choose>
						</b>
					</td>
				</tr>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="wellElevation">
		<xsl:for-each select="witsml:wellDatum">
			<xsl:if test="witsml:code = 'SL'">
				<xsl:variable name="sealevelUID"><xsl:value-of select="@uid"/></xsl:variable>
				<xsl:for-each select="../witsml:wellDatum">
					<xsl:if test="witsml:elevation/@datum = $sealevelUID">
						<xsl:variable name="datumCode"><xsl:value-of select="witsml:code"/></xsl:variable>
						<table border="1" width="90%">
							<tr>
								<th align="left" colspan="3" class='tableheader'>WELL ELEVATION</th>
							</tr>
							<tr>
								<td>Elevation of ground above sea level:  
									<b>
										<xsl:apply-templates select="../witsml:groundElevation" mode="valueWithUomRef"/>
									</b>
								</td>
								<td>All depth measurements taken from the top of:  
									<b>
										<xsl:choose>
											<xsl:when test="$datumCode = 'GL'">
												Ground Level
											</xsl:when>
											<xsl:when test="$datumCode = 'CF'">
												Casing Flange
											</xsl:when>
											<xsl:when test="$datumCode = 'CV'">
												Crown Valve
											</xsl:when>
											<xsl:when test="$datumCode = 'DF'">
												Derrick Floor
											</xsl:when>
											<xsl:when test="$datumCode = 'KB'">
												Kelly Bushing
											</xsl:when>
											<xsl:when test="$datumCode = 'RB'">
												Rotary Bushing
											</xsl:when>
											<xsl:when test="$datumCode = 'RT'">
												Rotary Table
											</xsl:when>
											<xsl:when test="$datumCode = 'SF'">
												Sea Floor
											</xsl:when>
											<xsl:when test="$datumCode = 'KO'">
												Kickoff Point
											</xsl:when>
											<xsl:otherwise>
												<xsl:value-of select="$datumCode"/>
											</xsl:otherwise>
										</xsl:choose>
									</b>
								</td>
								<td>That is:  
									<b>
										<xsl:value-of select="witsml:elevation - ../witsml:groundElevation"/>
										<xsl:text> </xsl:text>
										<xsl:apply-templates select="witsml:elevation" mode="UomRef"/>
									</b> above ground.
								</td>
							</tr>
						</table>
					</xsl:if>
				</xsl:for-each>
			</xsl:if>
		</xsl:for-each>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="directional">
		<xsl:if test="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHoleDispNs">
			<xsl:call-template name="directional_table">
				<xsl:with-param name="valueNS">
					<xsl:value-of select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHoleDispNs"/>
				</xsl:with-param>
				<xsl:with-param name="valueEW">
					<xsl:value-of select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHoleDispEw"/>
				</xsl:with-param>
				<xsl:with-param name="existence">Actual</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
		<xsl:if test="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHolePlannedDispNs">
			<xsl:call-template name="directional_table">
				<xsl:with-param name="valueNS">
					<xsl:value-of select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHolePlannedDispNs"/>
				</xsl:with-param>
				<xsl:with-param name="valueEW">
					<xsl:value-of select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHolePlannedDispEw"/>
				</xsl:with-param>
				<xsl:with-param name="existence">Plan</xsl:with-param>
			</xsl:call-template>
		</xsl:if>
	</xsl:template>
	<xsl:template name="directional_table">
		<xsl:param name="valueNS"/>
		<xsl:param name="valueEW"/>
		<xsl:param name="existence"/>
		<xsl:variable name="negativeOne">-1</xsl:variable>
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="2" class='tableheader'>DIRECTIONAL BOTTOM HOLE LOCATION</th>
			</tr>
			<tr>
				<td>Distance Bottom Hole is North or South From Surface Location:
					<b>
						<xsl:choose>
							<xsl:when test="$valueNS > 0">
								<xsl:value-of select="$valueNS"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$negativeOne * $valueNS"/>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text> </xsl:text>
						<xsl:apply-templates select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHoleDispNs" mode="UomRef"/>
					</b>
				</td>
				<td>Distance Bottom Hole is East or West From Surface Location:
					<b>
						<xsl:choose>
							<xsl:when test="$valueEW > 0">
								<xsl:value-of select="$valueEW"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$negativeOne * $valueEW"/>
							</xsl:otherwise>
						</xsl:choose>
						<xsl:text> </xsl:text>
						<xsl:apply-templates select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:bottomHoleDispEw" mode="UomRef"/>
					</b>
				</td>
			</tr>
			<tr>
				<td>Bottom Hole North or South Direction:
					<b>
						<xsl:choose>
							<xsl:when test="$valueNS > 0">
								North
							</xsl:when>
							<xsl:otherwise>
								South
							</xsl:otherwise>
						</xsl:choose>
					</b>
				</td>
				<td>Bottom Hole North or South Direction:
					<b>
						<xsl:choose>
							<xsl:when test="$valueEW > 0">
								East
							</xsl:when>
							<xsl:otherwise>
								West
							</xsl:otherwise>
						</xsl:choose>
					</b>
				</td>
			</tr>
			<tr>
				<td>True Vertical Depth at Total Depth:
					<b>
						<xsl:apply-templates select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:tvdPlanned" mode="valueWithUomRef"/>
					</b>
				</td>
				<td>Existence:
					<b>

						<xsl:choose>
							<xsl:when test="witsml:commonData/witsml:itemState='Plan'"> <!-- well -->
								Plan
							</xsl:when>
							<xsl:when test="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:commonData/witsml:itemState='Plan'"> <!-- wellbore -->
								Plan
							</xsl:when>
							<xsl:otherwise>
								<xsl:value-of select="$existence"/>
							</xsl:otherwise>
						</xsl:choose>
					</b>
				</td>


			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="usageType">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="7" class='tableheader'>WELL USAGE TYPE</th>
			</tr>
			<tr>
				<th>Well Usage Type</th>
				<th>Intended Zone</th>
				<th>Bottom TVD</th>
				<th>Top TVD</th>
				<th>Expected Pressure</th>
				<th>Existence</th>
			</tr>
			<xsl:for-each select="../witsml:wellboreSet/witsml:wellbore/witsml:classifiedIntervalSet/witsml:classifiedInterval">
				<xsl:if test="witsml:classification/witsml:namingSystem='CalWIMS well usage'">
					<tr>
						<td> 
							<b>
								<xsl:value-of select="witsml:classification/witsml:class"/>
							</b>
						</td>
						<td>  
							<b><xsl:value-of select="witsml:name"/></b>
						</td>
						<td>  
							<b>
								<xsl:apply-templates select="witsml:tvdBottom" mode="valueWithUomRef"/>
							</b>
						</td>
						<td>  
							<b>
								<xsl:apply-templates select="witsml:tvdTop" mode="valueWithUomRef"/>
							</b>
						</td>
						<td>  
							<b>
								<xsl:apply-templates select="witsml:pressure" mode="valueWithUomRef"/>
							</b>
						</td>
						<td>
							<b>
								<xsl:choose>
									<xsl:when test="witsml:commonData/witsml:itemState"> <!-- classifiedInterval -->
										<xsl:value-of select="witsml:commonData/witsml:itemState"/>
									</xsl:when>
									<xsl:when test="../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- wellbore -->
										<xsl:value-of select="../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
									</xsl:when>
									<xsl:when test="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"> <!-- well -->
										<xsl:value-of select="../../../../witsml:generalInformation/witsml:commonData/witsml:itemState"/>
									</xsl:when>
									<xsl:otherwise>
										Actual
									</xsl:otherwise>
								</xsl:choose>
							</b>
						</td>
					</tr>
				</xsl:if>
			</xsl:for-each>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="criticalWell">
		<table border="1" width="60%">
			<tr>
				<th align="left" class='tableheader'>CRITICAL WELL</th>
			</tr>
			<tr>
				<td>Is this a critical well according to the definition (default No)?:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='CriticalWell'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="wellProperties">
		<xsl:param name="formType"/>
		<table border="1" width="50%">
			<tr>
				<th align="left" class='tableheader'>WELL PROPERTIES</th>
			</tr>
			<tr>
				<td>Are you requesting Exploratory Status (default No)?:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='Exploratory'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Is this a Multilateral Well (default No)?:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='Multilateral'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Is this a Directional Well (default No)?:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='Directional'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Tidelands Surface Location (default Onshore): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='TidelandsSurfaceLocationOffshore'">
									Offshore	
								</xsl:if>	
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Estimated Total Depth: 
					<b>
						<xsl:choose>
							<xsl:when test="$formType = 'redrill'">
								<xsl:apply-templates select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:mdPlanned" mode="valueWithUomRef"/>
							</xsl:when>
							<xsl:otherwise>
								<xsl:apply-templates select="../witsml:wellboreSet/witsml:wellbore/witsml:generalInformation/witsml:mdcurrent" mode="valueWithUomRef"/>
							</xsl:otherwise>
						</xsl:choose>
					</b> 
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="mineralRights">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="2" class='tableheader'>MINERAL RIGHTS</th>
			</tr>
			<tr>
				<td colspan="2">Legal description of mineral rights consisting of 
					<b>
						<xsl:apply-templates select="witsml:mineralLease/witsml:area" mode="valueWithUomRef"/>
					</b> 
					<br/>
					(attach map or plat to scale in attachments screen) is as follows:
				</td>
			</tr>
			<tr>
				<td>Mineral-Right Lease Legal Description: 
					<br/>
					(Describe here or send attachment later in attachments screen.) 
				</td>
				<td width="65%"> 
					<b>
						<xsl:value-of select="witsml:mineralLease/witsml:legalDescription"/>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="surfaceLease">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="2" class='tableheader'>SURFACE LEASE</th>
			</tr>
			<tr>
				<td colspan="2">Do mineral and surface leases coincide (default No)?:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='MineralAndSurfaceLeasesCoincide'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
					<br/>
					If answer is no, enter legal description below (or attach map or plat to scale later in Attachments screen).
				</td>
			</tr>
			<tr>
				<td>Surface Lease Legal Description: 
					<br/>
					(Describe here or send attachment later in attachments screen.) 
				</td>
				<td width="65%"> 
					<b>
						<xsl:value-of select="witsml:surfaceLease/witsml:legalDescription"/>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="confidential">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="2" class='tableheader'>CONFIDENTIAL WELL STATUS</th>
			</tr>
			<tr>
				<td>Are you requesting confidential status for this well (default No)?:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='ConfidentialStatus'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
					<BR/>
					If yes, please provide reason below.
				</td>
			</tr>
			<tr>
				<td>Confidential Status Request Reason:  
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='ConfidentialStatus'">
									<xsl:value-of select="witsml:comment"/>	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	<xsl:template match="witsml:generalInformation" mode="CEQA">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="2" class='tableheader'>C. E. Q. A. INFORMATION</th>
			</tr>
			<tr>
				<td>Exempt (default No): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS Exempt'">
								Yes
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
				<td>Exempt Class:
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS Exempt'">
								<xsl:value-of select="witsml:class"/>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Negative Declaration (default No): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='NegativeDeclaration'">
									Yes
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
				<td>S.C.H. NO. or Document ID: 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='NegativeDeclaration'">
									<xsl:for-each select="../witsml:ancillaryDocument">
										<xsl:if test="witsml:kind/witsml:namingSystem='California CEQA'">
											<xsl:if test="witsml:kind/witsml:class='NegativeDeclaration'">
												<xsl:value-of select="witsml:alias/witsml:name"/>
											</xsl:if>
										</xsl:if>	
									</xsl:for-each>	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Evironmental Impact Report (default No): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='EvironmentalImpactReport'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
				<td>S.C.H. NO. or Document ID: 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='EvironmentalImpactReport'">
									<xsl:for-each select="../witsml:ancillaryDocument">
										<xsl:if test="witsml:kind/witsml:namingSystem='California CEQA'">
											<xsl:if test="witsml:kind/witsml:class='EvironmentalImpactReport'">
												<xsl:value-of select="witsml:alias/witsml:name"/>
											</xsl:if>
										</xsl:if>	
									</xsl:for-each>	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Document Not Required By Local Jurisdiction (default No): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='DocumentNotRequiredByLocalJurisdiction'">
									Yes	
								</xsl:if>
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>


	<xsl:template match="witsml:generalInformation" mode="wellLocation">
		<table border="1" width="90%">
			<tr>
				<th align="left" colspan="3" class='tableheader'>WELL LOCATION</th>
			</tr>
			<tr>
				<td>Lease Name: <b><xsl:value-of select="witsml:surfaceLease/witsml:name"/></b></td>
				<td>Well#: <b><xsl:apply-templates select="." mode="wellLocalFieldName"/></b></td>
				<td>District: <b><xsl:value-of select="witsml:district"/></b></td>
			</tr>
			<tr>
				<td>Section: <b><xsl:value-of select="witsml:legalLocation/witsml:USDescription/witsml:section"/></b></td>
				<td>Township: <b><xsl:value-of select="witsml:legalLocation/witsml:USDescription/witsml:township"/></b></td>
				<td>Range: <b><xsl:value-of select="witsml:legalLocation/witsml:USDescription/witsml:range"/></b></td>
			</tr>
			<tr>
				<td>Base and Meridian: <b><xsl:value-of select="witsml:legalLocation/witsml:USDescription/witsml:principalMeridian"/></b></td>
				<td>Field: <b><xsl:value-of select="witsml:field"/></b></td>
				<td>County: <b><xsl:value-of select="witsml:county"/></b></td>
			</tr>
			<tr>
				<td colspan="3"><small>Please enter Latitude and Longitude in NAD27 with six (6) decimal points accuracy (Example: "32.123456"). 
				For any urban wells, please submit a location map in the Attachments screen.</small></td>
			</tr>
			<tr>
				<td>Latitude: <b><xsl:apply-templates select="witsml:wellLocation/witsml:latitude" mode="valueWithUomRef"/></b></td>
				<td>Longitude: <b><xsl:apply-templates select="witsml:wellLocation/witsml:longitude" mode="valueWithUomRef"/></b></td>
			</tr>
			<tr>
				<td>Tidelands Surface Location (default Onshore): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='TidelandsSurfaceLocationOffshore'">
									Offshore	
								</xsl:if>	
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
			<tr>
				<td>Is this well on a BLM lease (default No): 
					<b>
						<xsl:for-each select="witsml:classification">
							<xsl:if test="witsml:namingSystem='CalWIMS classification'">
								<xsl:if test="witsml:class='WellOnBLMLease'">
									Yes	
								</xsl:if>	
							</xsl:if>
						</xsl:for-each>
					</b>
				</td>
			</tr>
		</table>
		<P> </P>
	</xsl:template>

	
	<xsl:template match="witsml:generalInformation" mode="wellLocalFieldName">
		<xsl:for-each select="witsml:wellAlias">
			<xsl:if test="witsml:namingSystem='Local Field'">
				<xsl:value-of select="witsml:name"/>
			</xsl:if>
		</xsl:for-each>
	</xsl:template>

<!--       				Uom attribute linked to the unit file.  		-->
	<xsl:template match="*" mode="UomRef">
		<xsl:call-template name="uomRefString">
			<xsl:with-param name="string" select="@uom"/>
			<xsl:with-param name="path" select="'../ancillaryData/witsmlUnitDict.html'"/>
		</xsl:call-template>
	</xsl:template>

<!--       				Measure value with a unit of measure linked to the unit file.  		-->
	<xsl:template match="*" mode="valueWithUomRef">
		<xsl:value-of select="."/>
		<xsl:text> </xsl:text>
		<xsl:call-template name="uomRefString">
			<xsl:with-param name="path" select="'../ancillaryData/witsmlUnitDict.html'"/>
		</xsl:call-template>
		<!-- In case this is a coordinate, check for datum. -->
		<xsl:if test="@datum">
			<xsl:text> </xsl:text>
			(<xsl:value-of select="@datum"/>)
		</xsl:if>
	</xsl:template>


	<!-- Template to create a name anchor or to create an href to a uom in the WITSML unit file. -->
	<!-- Add an underscore in front of Uppercase characters in the string. -->
	<!-- Also substitute T (times) and P (per) for period (.) and slash (/). -->
	<xsl:template name="uomRefString">
		<xsl:param name="string" select="@uom"/>    <!-- The uom string. -->
		<xsl:param name="index"  select="1"/>       <!-- The start index in the string. -->
		<xsl:param name="mode"   select="'href'"/>  <!-- 'href' or 'name'. -->
		<xsl:param name="path"   select="''"/>      <!-- Path to the unit file. Only relevant to 'href'. -->
		<xsl:choose>
			<xsl:when test="not($string)">
			<!-- For whatever reason, this value does not have a uom. -->
			<!-- It may be a unitless quantity or an indexed parameter with an optional uom. -->
			</xsl:when>
			<xsl:when test="$index > string-length($string)">
				-------- This is a bad call ----------
				string='<xsl:value-of select="$string"/>'
				index='<xsl:value-of select="$index"/>'
				mode='<xsl:value-of select="$mode"/>'
				path='<xsl:value-of select="$path"/>'
			</xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="_nextChar">
					<xsl:with-param name="string" select="$string"/>
					<xsl:with-param name="index" select="$index"/>
					<xsl:with-param name="mode" select="$mode"/>
					<xsl:with-param name="original" select="$string"/>
					<xsl:with-param name="path" select="$path"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--Template to examine the next character for an upper case letter. -->
	<xsl:template name="_nextChar">
		<xsl:param name="string"/>
		<xsl:param name="index"/>
		<xsl:param name="mode"/>
		<xsl:param name="original"/>
		<xsl:param name="path"/>
		<xsl:variable name="char"><xsl:value-of select="substring($string,$index,1)"/></xsl:variable>
		<xsl:variable name="len"><xsl:value-of select="string-length($string)"/></xsl:variable>
		<xsl:choose>
			<xsl:when test="not($string)"/>
			<xsl:when test="$index > $len">
				<!-- We are finished -->
				<xsl:if test="$mode = 'href'">
					<a href="{$path}#uom::{translate($string,'./','TP')}"><xsl:value-of select="$original"/></a>
				</xsl:if>
				<xsl:if test="$mode = 'name'">
					<a name="uom::{translate($string,'./','TP')}"/>
				</xsl:if>
			</xsl:when>
			<xsl:when test="$char='A'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='B'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='C'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='D'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='E'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='F'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='G'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='H'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='I'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='J'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='K'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='L'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='M'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='N'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='O'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='P'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='Q'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='R'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='S'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='T'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='U'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='V'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='W'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='X'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='Y'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:when test="$char='Z'"><xsl:call-template name="_insertChar"><xsl:with-param name="string" select="$string"/>
						   <xsl:with-param name="index" select="$index"/><xsl:with-param name="mode" select="$mode"/>
						   <xsl:with-param name="original" select="$original"/><xsl:with-param name="path" select="$path"/>
						   </xsl:call-template></xsl:when>
			<xsl:otherwise>
				<xsl:call-template name="_nextChar">
					<xsl:with-param name="string" select="$string"/>
					<xsl:with-param name="index" select="$index +1"/>
					<xsl:with-param name="mode" select="$mode"/>
					<xsl:with-param name="original" select="$original"/>
					<xsl:with-param name="path" select="$path"/>
				</xsl:call-template>
			</xsl:otherwise>
		</xsl:choose>
	</xsl:template>
	<!--Template to insert an underscore at the current index while calling _nextChar. -->
	<xsl:template name="_insertChar">
		<xsl:param name="string"/>
		<xsl:param name="index"/>
		<xsl:param name="mode"/>
		<xsl:param name="original"/>
		<xsl:param name="path"/>
		<xsl:variable name="len"><xsl:value-of select="string-length($string)"/></xsl:variable>
		<xsl:call-template name="_nextChar">
			<xsl:with-param name="string" select="concat(substring($string,1,$index - 1),'_',substring($string,$index,$len - $index +1))"/>
			<xsl:with-param name="index" select="$index +2"/>
			<xsl:with-param name="mode" select="$mode"/>
			<xsl:with-param name="original" select="$original"/>
			<xsl:with-param name="path" select="$path"/>
		</xsl:call-template>
	</xsl:template>

</xsl:stylesheet>
