<?xml version="1.0"?>
<xsl:stylesheet xmlns="http://www.courts.state.mn.us/02/MW" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
	<xsl:output method="xml" indent="yes"/>

	<xsl:variable name="editPass">Pass</xsl:variable>
	<xsl:variable name="editWarn">Warn</xsl:variable>
	<xsl:variable name="messageIdentification">Case:<xsl:value-of select="Pipeline/SourceXML/Integration/Case/CaseNumber"/></xsl:variable>

	<xsl:template match="/">
		<EditReport>
			<xsl:if test="Pipeline/SourceXML/Integration[(ControlPoint='SAVE-CR-DISPOSITION') or (ControlPoint='SAVE-CR-SENTENCE') or (ControlPoint='SAVE-CR-PLEA')]/Case[Expunged!='true']/CaseType[(substring(@Word, 1, 3)!='CNV')][(@Word!='OUT')]">
				<xsl:call-template name="EditDefDOB"/>
			</xsl:if>
		</EditReport>
	</xsl:template>

	<xsl:template name="EditDefDOB">
		<!--Missing Birth Date for Defendant-->
		<xsl:for-each select="Pipeline/SourceXML/Integration/Case/Charge[(@Op='E') and (((Deleted!='true') or (string-length(Deleted)=0)) and ((string-length(Deleted/@Op)=0) or (Deleted/@Op!='D')))]">
			<xsl:variable name="vChargeID" select="@ID"/>

			<!--<xsl:if test="//DispositionEvent[(@Op!='D') or  (string-length(@Op)=0)]/Disposition[((@Op!='D') or (string-length(@Op)=0)) and ($vChargeID=@ChargeID)]">-->
				<!--Check if Charge is disposed-->
				<!--<xsl:if test="((../BaseCaseType!='Juvenile') and (count(ChargeHistory[(((Deleted!='true') or (string-length(Deleted)=0)) and ((Deleted/@Op!='D') or (string-length(Deleted/@Op)=0))) and ((Statute/Degree/@Word='FEL') or (Statute/Degree/@Word='GMD') or (Additional/TargetedMisdemeanor ='true'))])&gt;0) ) or ((../BaseCaseType='Juvenile') and (count(ChargeHistory[(((Deleted!='true') or (string-length(Deleted)=0)) and ((Deleted/@Op!='D') or (string-length(Deleted/@Op)=0))) and  ((Statute/Degree/@Word='FEL') or (Statute/Degree/@Word='GMD'))])&gt;0) )">-->
					<xsl:if test="(ChargeHistory[@CurrentCharge='true']/Statute[LegacyReferenceID!='12112' and LegacyReferenceID!='12113'])">
						<!--<xsl:for-each select='Pipeline/SourceXML/Integration/Case/CaseParty[(Connection/@BaseConnection="DF") and (string-length(Connection/RemovedReason/@Word)=0)]'>-->
						<xsl:if test='//CaseParty[(Connection/@BaseConnection="DF") and (string-length(Connection/RemovedReason/@Word)=0)]'>
							<xsl:variable name="vPartyID">
								<xsl:value-of select="@PartyID"/>
							</xsl:variable>
							<EditResult>
								<EditNumber>5</EditNumber>
								<ItemIdentification>Defendant Date of Birth</ItemIdentification>
								<Result>
									<!--<xsl:for-each select="//Party[@ID = $vPartyID]">-->
									<xsl:for-each select="//Party[@ID = $vPartyID]">
										<xsl:choose>
											<xsl:when test="PartyName[@Current='true']/NameType = 'Business'">
												<xsl:value-of select="$editPass"/>
											</xsl:when>
											<xsl:when test="string-length(DateOfBirth) !=0">
												<xsl:value-of select="$editPass"/>
											</xsl:when>
											<xsl:otherwise>
												<xsl:value-of select="$editWarn"/>
											</xsl:otherwise>
										</xsl:choose>
									</xsl:for-each>
								</Result>
							</EditResult>
						</xsl:if>
						<!--</xsl:for-each>-->
					</xsl:if>
				<!--</xsl:if>-->
			<!--</xsl:if>-->
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet><!-- Stylus Studio meta-information - (c) 2004-2009. Progress Software Corporation. All rights reserved.

<metaInformation>
	<scenarios>
		<scenario default="yes" name="Scenario1" userelativepaths="yes" externalpreview="no" url="winkimjr2.xml" htmlbaseurl="" outputurl="" processortype="saxon8" useresolver="yes" profilemode="0" profiledepth="" profilelength="" urlprofilexml=""
		          commandline="" additionalpath="" additionalclasspath="" postprocessortype="none" postprocesscommandline="" postprocessadditionalpath="" postprocessgeneratedext="" validateoutput="no" validator="internal" customvalidator="">
			<advancedProp name="bSchemaAware" value="true"/>
			<advancedProp name="xsltVersion" value="2.0"/>
			<advancedProp name="bUseDTD" value="false"/>
			<advancedProp name="bXml11" value="false"/>
			<advancedProp name="bWarnings" value="true"/>
			<advancedProp name="iWhitespace" value="0"/>
			<advancedProp name="schemaCache" value="||"/>
			<advancedProp name="bXsltOneIsOkay" value="true"/>
			<advancedProp name="bTinyTree" value="true"/>
			<advancedProp name="bGenerateByteCode" value="true"/>
			<advancedProp name="iValidation" value="0"/>
			<advancedProp name="bExtensions" value="true"/>
			<advancedProp name="sInitialMode" value=""/>
			<advancedProp name="sInitialTemplate" value=""/>
			<advancedProp name="iErrorHandling" value="fatal"/>
		</scenario>
	</scenarios>
	<MapperMetaTag>
		<MapperInfo srcSchemaPathIsRelative="yes" srcSchemaInterpretAsXML="no" destSchemaPath="" destSchemaRoot="" destSchemaPathIsRelative="yes" destSchemaInterpretAsXML="no"/>
		<MapperBlockPosition></MapperBlockPosition>
		<TemplateContext></TemplateContext>
		<MapperFilter side="source"></MapperFilter>
	</MapperMetaTag>
</metaInformation>
-->