I would like to get the following output from my xml document. When the dateofbirth is present in the input document (xml doc) I want the result to show pass.
Expected
My output which is wrong
Xml document
stylesheet
Expected
Code:
<?xml version="1.0" encoding="UTF-16"?>
<EditReport xmlns="[URL unfurl="true"]http://www.courts.state.mn.us/02/MW">[/URL]
<EditResult>
<EditNumber>5</EditNumber>
<ItemIdentification>Defendant Date of Birth</ItemIdentification>
<Result>Pass</Result>
</EditResult>
</EditReport>
My output which is wrong
Code:
<?xml version="1.0" encoding="UTF-16"?>
<EditReport xmlns="[URL unfurl="true"]http://www.courts.state.mn.us/02/MW">[/URL]
<EditResult>
<EditNumber>5</EditNumber>
<ItemIdentification>Defendant Date of Birth</ItemIdentification>
<Result/>
</EditResult>
</EditReport>
Xml document
XML:
<Pipeline>
<SourceXML>
<Integration>
<ControlPoint>SAVE-CR-SENTENCE</ControlPoint>
<Case>
<CaseCategory>CR</CaseCategory>
<CaseType Word="CRM">Crim/Traf Mandatory</CaseType>
<BaseCaseType>Adult</BaseCaseType>
<Expunged>false</Expunged>
<DispositionEvent Op="A"/>
<CaseParty ID="17321520" InternalCasePartyID="1648995659" InternalPartyID="1615875612">
<Connection Word="DFD" BaseConnection="DF"/>
</CaseParty>
<Charge Op="E" ID="13562795" PartyID="17321520">
<ChargeHistory ChargeHistoryID="53109803" Stage="Case Filing" FilingSequence="1" InternalOffenseHistoryID="1661499994">
<ChargeNumber>1</ChargeNumber>
<Statute>
<LegacyReferenceID>12891</LegacyReferenceID>
<Degree Word="MSD">Gross Misdemeanor</Degree>
</Statute>
<Additional>
<TargetedMisdemeanor>false</TargetedMisdemeanor>
</Additional>
<Deleted>false</Deleted>
</ChargeHistory>
<ChargeHistory Op="A" ChargeHistoryID="55339617" Stage="Disposition Event" DispositionEventSequence="1" CurrentCharge="true">
<ChargeNumber Op="A">1</ChargeNumber>
<Statute>
<LegacyReferenceID Op="A">12173</LegacyReferenceID>
<Degree Op="A" Word="MSD">Gross Misdemeanor</Degree>
</Statute>
<Additional>
<TargetedMisdemeanor Op="A">false</TargetedMisdemeanor>
</Additional>
<Deleted Op="A">false</Deleted>
</ChargeHistory>
<Deleted>false</Deleted>
</Charge>
</Case>
<Party ID="17321520" InternalPartyID="1615875612">
<DateOfBirth Current="true">04/15/1968</DateOfBirth>
<PartyName ID="12071722" InternalNameID="1618898170">
<NameType>Standard</NameType>
</PartyName>
</Party>
</Integration>
</SourceXML>
</Pipeline>
stylesheet
Code:
<xsl:stylesheet xmlns="[URL unfurl="true"]http://www.courts.state.mn.us/02/MW"[/URL] xmlns:xsl="[URL unfurl="true"]http://www.w3.org/1999/XSL/Transform"[/URL] version="1.0">
<xsl:output method="xml"/>
<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">
<xsl:value-of select="@ID"/>
</xsl:variable>
<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'))])>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'))])>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="@ID"/>
</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>