How do I loop through several Charges and then display value

Here should go questions about transforming XML with XSLT and FOP.
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

How do I loop through several Charges and then display value

Post by winkimjr2 » Fri May 01, 2015 10:47 pm

I have a xml document with several charges. I would like for each unique ChargeID evaluate the ChargeHistory records. If, Stage=”Disposition Event” is found verify the number of DispositionEventSequence. If only “1” populate Charge Information, otherwise use the highest DispositionEventSequence to populate.

If no Stage=”Disposition Event” is found look for Stage=”Case Filing” to populate. If only “1” populate Charge information, otherwise use the highest Case Filing Filing Sequence to populate.

xml

Code: Select all

<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="IXML Case Notification Test" MessageID="67078424" xmlns="">
<Case InternalID="1616807927" ID="11747370" xmlns:user="http://tylertechnologies.com">
<Charge ID="10547226" PartyID="16580814" CurrSentenceID="155092098" InternalChargeID="1616447618" InternalPartyID="1614482843" xmlns:reslib="urn:reslib">
<ChargeOffenseDate>03/26/2014</ChargeOffenseDate>
<ChargeHistory ChargeHistoryID="41858685" Stage="Disposition Event" DispositionEventSequence="1" InternalOffenseHistoryID="1636250409">
<ChargeNumber>1</ChargeNumber>
<ChargeOffenseDate deprecated="true">03/26/2014</ChargeOffenseDate>
<Statute>
<StatuteDescription>Traffic Regulations - Failure to obey traffic control device</StatuteDescription>
<StatuteCode Word="169064a" InternalCodeID="66247">Traffic Regulations - Failure to obey traffic control device</StatuteCode>
<Degree Word="PMD">Petty Misdemeanor</Degree>
</Statute>
<Additional>
<LocationOfViolation>Hwy 15 & Century Ave</LocationOfViolation>
</Additional>
</ChargeHistory>
<ChargeHistory ChargeHistoryID="42932967" Stage="Disposition Event" DispositionEventSequence="2" CurrentCharge="true" InternalOffenseHistoryID="1637028595">
<ChargeNumber>1</ChargeNumber>
<ChargeOffenseDate deprecated="true">03/26/2014</ChargeOffenseDate>
<Statute>
<StatuteDescription>Traffic Regulations - Failure to obey traffic control device</StatuteDescription>
<StatuteCode Word="169064a" InternalCodeID="66247">Traffic Regulations - Failure to obey traffic control device</StatuteCode>
<LegacyReferenceID>14526</LegacyReferenceID>
<Degree Word="PMD">Petty Misdemeanor</Degree>
</Statute>
<Additional>
<LocationOfViolation>Hwy 15 & Century Ave</LocationOfViolation>
</Additional>
</ChargeHistory>
</Charge>
<Charge ID="10547227" PartyID="16580815" CurrSentenceID="155092099" InternalChargeID="1616447619" InternalPartyID="1614482844" xmlns:reslib="urn:reslib">
<ChargeOffenseDate>03/26/2014</ChargeOffenseDate>
<ChargeHistory ChargeHistoryID="41858686" Stage="Disposition Event" DispositionEventSequence="1" InternalOffenseHistoryID="1636250400">
<ChargeNumber>2</ChargeNumber>
<ChargeOffenseDate deprecated="true">03/26/2014</ChargeOffenseDate>
<Statute>
<StatuteDescription>Traffic Regulations - Failure to obey traffic control device</StatuteDescription>
<StatuteCode Word="169064a" InternalCodeID="66247">Traffic Regulations - Failure to obey traffic control device</StatuteCode>
<Degree Word="PMD">Petty Misdemeanor</Degree>
</Statute>
<Additional>
<LocationOfViolation>Hwy 15 & Century Ave</LocationOfViolation>
</Additional>
</ChargeHistory>
<ChargeHistory ChargeHistoryID="42932967" Stage="Disposition Event" DispositionEventSequence="2" CurrentCharge="true" InternalOffenseHistoryID="1637028595">
<ChargeNumber>3</ChargeNumber>
<ChargeOffenseDate deprecated="true">03/26/2014</ChargeOffenseDate>
<Statute>
<StatuteDescription>Traffic Regulations - Failure to obey traffic control device</StatuteDescription>
<StatuteCode Word="169064a" InternalCodeID="66247">Traffic Regulations - Failure to obey traffic control device</StatuteCode>
<LegacyReferenceID>14524</LegacyReferenceID>
<Degree Word="PMD">Petty Misdemeanor</Degree>
</Statute>
<Additional>
<LocationOfViolation>Hwy 15 & Century Ave</LocationOfViolation>
</Additional>
</ChargeHistory>
<ChargeHistory ChargeHistoryID="41490828" Stage="Case Filing" FilingSequence="1" InternalOffenseHistoryID="1635954993">
<ChargeNumber>2</ChargeNumber>
<Jurisdiction Word="43H">Hutchinson</Jurisdiction>
<ChargeOffenseDate deprecated="true">03/26/2014</ChargeOffenseDate>
<ChargeFilingDate>04/02/2014</ChargeFilingDate>
<Statute>
<StatuteNumber>169.06.4(a)</StatuteNumber>
<StatuteDescription>Traffic Regulations - Failure to obey traffic control device</StatuteDescription>
<StatuteCode Word="169064a" InternalCodeID="66247">Traffic Regulations - Failure to obey traffic control device</StatuteCode>
<LegacyReferenceID>14524</LegacyReferenceID>
<Degree Word="PMD">Petty Misdemeanor</Degree>
</Statute>
<Additional>
<LocationOfViolation>Hwy 15 & Century Ave</LocationOfViolation>
</Additional>
</ChargeHistory>
</Charge>
</Case>
</Integration>
xslt. How do I change this code to make it work?

Code: Select all

<xsl:template name="Charge">
<ext:Charge>
<xsl:for-each select="/Integration/Case/Charge/ChargeHistory[@Stage='Disposition Event']">
<xsl:sort select="@DispositionEventSequence" data-type="number" order="descending"/>
<xsl:if test="position()=1">
<j:ChargeSequenceID>
<xsl:value-of select="ChargeNumber"/>
</j:ChargeSequenceID>
<j:ChargeStatute>
<j:StatuteDescriptionText>
<xsl:value-of select="Statute/StatuteCode"/>
</j:StatuteDescriptionText>
<j:StatuteText>
<xsl:value-of select="Statute/StatuteCode/@Word"/>
</j:StatuteText>
</j:ChargeStatute>
<j:ChargeSeverityDescriptionText>
<xsl:value-of select="Statute/Degree"/>
</j:ChargeSeverityDescriptionText>
</xsl:if>
</xsl:for-each>
</ext:Charge>
</xsl:template>

Radu
Posts: 6541
Joined: Fri Jul 09, 2004 5:18 pm

Re: How do I loop through several Charges and then display v

Post by Radu » Mon May 04, 2015 3:34 pm

Hi,

You should try to address XSLT-related questions to the XSLT users list or on Stack Overflow:

http://www.mulberrytech.com/xsl/xsl-list/

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com

Post Reply