×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

How do I get the correct output in xslt?

How do I get the correct output in xslt?

How do I get the correct output in xslt?

(OP)
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

CODE --> xslt

<?xml version="1.0" encoding="UTF-16"?>
<EditReport xmlns="http://www.courts.state.mn.us/02/MW">
	<EditResult>
		<EditNumber>5</EditNumber>
		<ItemIdentification>Defendant Date of Birth</ItemIdentification>
		<Result>Pass</Result>
	</EditResult>
</EditReport> 

My output which is wrong

CODE --> xslt

<?xml version="1.0" encoding="UTF-16"?>
<EditReport xmlns="http://www.courts.state.mn.us/02/MW">
	<EditResult>
		<EditNumber>5</EditNumber>
		<ItemIdentification>Defendant Date of Birth</ItemIdentification>
		<Result/>
	</EditResult>
</EditReport> 


Xml document

CODE --> 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 --> xslt

<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"/>
	<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> 

RE: How do I get the correct output in xslt?

Shouldn't it be...

CODE --> XSLT

<!-- stuff -->
							<xsl:variable name="vPartyID">
								<xsl:value-of select="@PartyID"/>
							</xsl:variable>
<!-- stuff --> 
?

RE: How do I get the correct output in xslt?

(OP)
Thanks atlopes

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close