×
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

I expect result to be true but I get false

I expect result to be true but I get false

I expect result to be true but I get false

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

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

<?xml version="1.0" encoding="UTF-16"?>
<EditReport>
	<EditResult>
		<EditNumber>4</EditNumber>
		<ItemIdentification>Charge:</ItemIdentification>
		<flag>false</flag>
	</EditResult>
</EditReport> 

My xml input

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

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet 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: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> 

RE: I expect result to be true but I get false

(OP)
I solved this one. I do not need any help.
Here is what I added

CODE --> xslt

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

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