Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

I expect result to be true but I get false

Status
Not open for further replies.

momo2000

Programmer
Jan 2, 2015
63
US
My xslt is not working as I expect it to. I expect to get <flag>true</flag> but my output is displaying <flag>false</flag>
The result I want should look like this.
Code:
<?xml version="1.0" encoding="UTF-16"?>
<EditReport>
	<EditResult>
		<EditNumber>4</EditNumber>
		<ItemIdentification>Charge:</ItemIdentification>
		<flag>true</flag>
	</EditResult>
</EditReport>

However, this is what I am getting.
Code:
<?xml version="1.0" encoding="UTF-16"?>
<EditReport>
	<EditResult>
		<EditNumber>4</EditNumber>
		<ItemIdentification>Charge:</ItemIdentification>
		<flag>false</flag>
	</EditResult>
</EditReport>

My xml input
XML:
<Pipeline>
	<SourceXML>
		<Integration>
			<Case>
				<Charge Op="E" ID="13661210" >
					<ChargeHistory ChargeHistoryID="53438802" Stage="Case Filing" FilingSequence="1" InternalOffenseHistoryID="1661667423">
						<ChargeNumber>1</ChargeNumber>
						<Statute>
							<Degree Word="MSD">Misdemeanor</Degree>
						</Statute>
						<Deleted>false</Deleted>
					</ChargeHistory>
					<ChargeHistory Op="A" ChargeHistoryID="53438803" Stage="Disposition Event" DispositionEventSequence="1" CurrentCharge="true" InternalOffenseHistoryID="1661667424">
						<ChargeNumber Op="A">1</ChargeNumber>
						<Statute>
							<Degree Op="A" Word="MSD">Misdemeanor</Degree>
						</Statute>
						<Additional/>
						<Deleted Op="A">false</Deleted>
					</ChargeHistory>
					<Deleted>false</Deleted>
				</Charge>
			</Case>
		</Integration>
	</SourceXML>
</Pipeline>


My xslt stylesheet
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 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:call-template name="EditChargeControlNumber"/>
		</EditReport>
	</xsl:template>
	<xsl:template name="EditChargeControlNumber">
		<!--Missing Control Number-->
		<xsl:for-each select="Pipeline/SourceXML/Integration/Case/Charge[(Deleted!='true') or (string-length(Deleted)=0)]">
			<xsl:variable name="vFilChrgHistID">
				<xsl:for-each select="Pipeline/SourceXML/Integration/Case/Charge/ChargeHistory[(Deleted!='true') or (string-length(Deleted)=0)][(@Stage='Case Filing')]">
					<xsl:sort select="@FilingSequence"/>
					<xsl:if test="position()=last()">
						<xsl:value-of select="@ChargeHistoryID"/>
					</xsl:if>
				</xsl:for-each>
			</xsl:variable>
			<xsl:variable name="vPettyOrNonTargMsd">
				<xsl:choose>
					<xsl:when test="ChargeHistory[@ChargeHistoryID=$vFilChrgHistID]/Statute/Degree/@Word='PMD'">true</xsl:when>
					<xsl:when test="(ChargeHistory[@ChargeHistoryID=$vFilChrgHistID]/Statute/Degree/@Word='MSD') and (ChargeHistory[@ChargeHistoryID=$vFilChrgHistID]/Additional/TargetedMisdemeanor='false')">true</xsl:when>
					<xsl:otherwise>false</xsl:otherwise>
				</xsl:choose>
			</xsl:variable>
			<EditResult>
				<EditNumber>4</EditNumber>
				<ItemIdentification>Charge:<xsl:value-of select='Pipeline/SourceXML/Integration/Case/Charge/ChargeHistory[(Deleted!="true") or (string-length(Deleted)=0)][@CurrentCharge="true"]/ChargeNumber'/>
				</ItemIdentification>
				<flag>
					<xsl:value-of select="$vPettyOrNonTargMsd"/>
				</flag>
			</EditResult>
		</xsl:for-each>
	</xsl:template>
</xsl:stylesheet>
 
I solved this one. I do not need any help.
Here is what I added
Code:
<xsl:when test="(ChargeHistory[@ChargeHistoryID=$vFilChrgHistID]/Statute/Degree/@Word='MSD') and ((ChargeHistory[@ChargeHistoryID=$vFilChrgHistID]/Additional/TargetedMisdemeanor='false') or (string-length(ChargeHistory[@ChargeHistoryID=$vFilChrgHistID]/Additional/TargetedMisdemeanor)=0)">true</xsl:when>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top