Wrox Programmer Forums
Go Back   Wrox Programmer Forums > XML > XSLT
|
XSLT General questions and answers about XSLT. For issues strictly specific to the book XSLT 1.1 Programmers Reference, please post to that forum instead.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XSLT section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 5th, 2015, 07:09 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How to I get and display ChargeID?

What I am trying to do is get the ChargeID=10485838 . To get this chargeID, I need to look in the ChargeHistory element for the Stage="Plea Event" and find the PleaEventSequence value with the highest event number (for example PleaEventSequence="2") and then find the Plea in the PleaEvent node whose ChargeHistoryID matches the Charge node's ChargeHistoryID . In my case this would be ChargeHistoryID="41274044".
Someone please help me with his one.

My xml code
Code:
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="ChargeDispSent" MessageID="57834892" xmlns="">
   <ControlPoint Timestamp="1/7/2015 9:15:07 AM" UserID="CunninghamC">SAVE-CR-PLEA</ControlPoint>
   <Case InternalID="1616760662" ID="11683904" xmlns:user="http://tylertechnologies.com">
      <PleaEvent Date="01/07/2015" ID="151480108" InternalPleaEventID="1714733342" xmlns:reslib="urn:reslib">
         <PleaEventDate>01/07/2015</PleaEventDate>
         <TimestampCreate>01/07/2015 09:14:48:533</TimestampCreate>
         <PleaAmendmentReason Word="PLA">Plea agreement</PleaAmendmentReason>
         <Plea ChargeID="10485838" ChargeHistoryID="41274044" InternalChargeID="1616399897" InternalOffenseHistoryID="1635787112">
            <PleaType Word="GUI">Guilty</PleaType>
         </Plea>
         <PleaEvent Date="01/07/2015" ID="151480102" InternalPleaEventID="1714733336">
            <PleaEventDate>01/07/2015</PleaEventDate>
            <TimestampCreate>01/07/2015 09:10:29:813</TimestampCreate>
            <Plea ChargeID="10485838" ChargeHistoryID="41274038" InternalChargeID="1616399897" InternalOffenseHistoryID="1635787106">
               <PleaType Word="NGUI">Not guilty</PleaType>
            </Plea>
            <Plea ChargeID="10485839" ChargeHistoryID="41274039" InternalChargeID="1616399898" InternalOffenseHistoryID="1635787107">
               <PleaType Word="NGUI">Not guilty</PleaType>
            </Plea>
         </PleaEvent>
      </PleaEvent>
      <PleaEvent Op="A" Date="01/07/2015" ID="151480109" InternalPleaEventID="1714733343" xmlns:reslib="urn:reslib">
         <PleaEventDate Op="A">01/07/2015</PleaEventDate>
         <TimestampCreate Op="A">01/07/2015 09:15:07:360</TimestampCreate>
         <PleaAmendmentReason Op="A" Word="PLA">Plea agreement</PleaAmendmentReason>
         <Plea Op="A" ChargeID="10485839" ChargeHistoryID="41274045" InternalChargeID="1616399898" InternalOffenseHistoryID="1635787113">
            <PleaType Op="A" Word="GUI">Guilty</PleaType>
         </Plea>
         <PleaEvent Op="E" Date="01/07/2015" ID="151480103" InternalPleaEventID="1714733337">
            <PleaEventDate>01/07/2015</PleaEventDate>
            <TimestampCreate>01/07/2015 09:11:13:770</TimestampCreate>
            <PleaAmendmentReason Word="AMENDC">Amended complaint</PleaAmendmentReason>
            <Plea ChargeID="10485839" ChargeHistoryID="41274040" InternalChargeID="1616399898" InternalOffenseHistoryID="1635787108">
               <PleaType Word="NONE">None</PleaType>
            </Plea>
            <PleaEvent Date="01/07/2015" ID="151480102" InternalPleaEventID="1714733336">
               <PleaEventDate>01/07/2015</PleaEventDate>
               <TimestampCreate>01/07/2015 09:10:29:813</TimestampCreate>
               <Plea ChargeID="10485838" ChargeHistoryID="41274038" InternalChargeID="1616399897" InternalOffenseHistoryID="1635787106">
                  <PleaType Word="NGUI">Not guilty</PleaType>
               </Plea>
               <Plea ChargeID="10485839" ChargeHistoryID="41274039" InternalChargeID="1616399898" InternalOffenseHistoryID="1635787107">
                  <PleaType Word="NGUI">Not guilty</PleaType>
               </Plea>
            </PleaEvent>
         </PleaEvent>
      </PleaEvent>
      <Charge ID="10485838" PartyID="16548350" InternalChargeID="1616399897" InternalPartyID="1614451487" xmlns:reslib="urn:reslib">
         <ChargeOffenseDate>01/06/2015</ChargeOffenseDate>
         <ChargeHistory ChargeHistoryID="41274035" Stage="Arrest" ArrestSequence="1" InternalOffenseHistoryID="1635787103">
            <ChargeNumber>1</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274034" Stage="Case Filing" FilingSequence="1" InternalOffenseHistoryID="1635787102">
            <ChargeNumber>1</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274038" Stage="Plea Event" PleaEventSequence="1" InternalOffenseHistoryID="1635787106">
            <ChargeNumber>1</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274044" Stage="Plea Event" PleaEventSequence="2" CurrentCharge="true" InternalOffenseHistoryID="1635787112">
            <ChargeNumber>1</ChargeNumber>
         </ChargeHistory>
      </Charge>
      <Charge Op="E" ID="10485839" PartyID="16548350" InternalChargeID="1616399898" InternalPartyID="1614451487" xmlns:reslib="urn:reslib">
         <ChargeOffenseDate>01/06/2015</ChargeOffenseDate>
         <DateOnOrAbout>false</DateOnOrAbout>
         <ChargeHistory ChargeHistoryID="41274037" Stage="Arrest" ArrestSequence="1" InternalOffenseHistoryID="1635787105">
            <ChargeNumber>2</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274036" Stage="Case Filing" FilingSequence="1" InternalOffenseHistoryID="1635787104">
            <ChargeNumber>2</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274041" Stage="Case Filing" FilingSequence="2" InternalOffenseHistoryID="1635787109">
            <ChargeNumber>2</ChargeNumber>
            <AmendedDate>01/07/2015</AmendedDate>
            <AmendedReason Word="RED">Reduced</AmendedReason>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274043" Stage="Case Filing" FilingSequence="3" InternalOffenseHistoryID="1635787111">
            <ChargeNumber>2</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274039" Stage="Plea Event" PleaEventSequence="1" InternalOffenseHistoryID="1635787107">
            <ChargeNumber>2</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory ChargeHistoryID="41274040" Stage="Plea Event" PleaEventSequence="2" InternalOffenseHistoryID="1635787108">
            <ChargeNumber>2</ChargeNumber>
         </ChargeHistory>
         <ChargeHistory Op="A" ChargeHistoryID="41274045" Stage="Plea Event" PleaEventSequence="3" CurrentCharge="true" InternalOffenseHistoryID="1635787113">
            <ChargeNumber Op="A">2</ChargeNumber>
         </ChargeHistory>
      </Charge>
   </Case>
   <IntegrationConditions>
      <IntegrationCondition Word="CHARGE" Description="Charge">
         <NotificationEvent notificationType="ChargeNotification" elementState="PreDisposition" elementName="Charge" elementKey="10485839">PleaAmended</NotificationEvent>
      </IntegrationCondition>
   </IntegrationConditions>
</Integration>
My xslt template code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<?altova_samplexml file:///Z:/Training%20with%20Tim%20XML%20code%20various/PleaFix.xml?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:fn="http://www.w3.org/2005/xpath-functions">
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
   <xsl:template match="/">
      <xsl:variable name="vPleaEventID">
         <xsl:call-template name="GetChargePleaEventID">
            <xsl:with-param name="pChargeID"></xsl:with-param>
         </xsl:call-template>
      </xsl:variable>
      <result>
         <xsl:value-of select="$vPleaEventID"/>
      </result>
   </xsl:template>
   <!--   
   -->
   <xsl:template name="GetChargePleaEventID">
      <xsl:param name="pChargeID"/>
      <!--<xsl:text>12345</xsl:text>-<xsl:value-of select="$pChargeID"/>-->
   </xsl:template>
</xsl:stylesheet>

Last edited by winkimjr2; February 6th, 2015 at 11:53 AM.. Reason: Explained in a better way what I want
 
Old February 6th, 2015, 04:32 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default Resloved

I have resolved this by adding 2 variables.
XSLT code
<xsl:variable name="vInternalOffenseHistoryID" xmlns:xsl="#unknown">
<xsl:value-of select="//Charge[@ID=$pChargeID]/ChargeHistory[@Stage='Plea Event'][last()]/@InternalOffenseHistoryID" />
</xsl:variable>
<xsl:variable name="vPleaEventID" xmlns:xsl="#unknown">
<xsl:value-of select="//PleaEvent[count(Plea[@InternalOffenseHistoryID=$vInternalOffenseHistory ID])>0]/@ID" />
</xsl:variable>
<xsl:value-of select="$vPleaEventID" />





Similar Threads
Thread Thread Starter Forum Replies Last Post
Form Data Will Not Display When I Click On Display Button sprdave BOOK: Beginning C# 3.0 : An Introduction to Object Oriented Programming ISBN: 978-0-470-26129-3 12 February 13th, 2011 12:09 AM
Display Row No. yogeshyl SQL Language 6 July 7th, 2008 02:11 PM
display annumol Hibernate 1 March 21st, 2008 03:43 PM
Display javaLös Java GUI 5 May 12th, 2005 12:29 PM
can't display syounger JSP Basics 3 February 12th, 2004 07:46 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.