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 December 30th, 2014, 06:46 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How can I display ObservedEthnicity for the Respondent?

I have xml code with several CaseParty. The problem is that, my xslt is displaying ObservedEthnicity for the first found CaseParty which is not a Respondent.
How do I change it to display the correct ObservedEthnicity for the Respondent?

Wrong output
Code:
<ext:Respondent>
	<nc:PersonEthnicityCode>N</nc:PersonEthnicityCode>
	<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1966-01-02</ext:PersonBirthDate>
	<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="false">1966-02-02</ext:PersonBirthDate>
	<ext:PersonName ext:currentIndicator="true">
	<nc:PersonFullName>Respondent, Richard S</nc:PersonFullName>
	</ext:PersonName>
</ext:Respondent>

Here is my xml code
Code:
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com">
<Case InternalID="1616760296" ID="11683548" xmlns:user="http://tylertechnologies.com">
   <CaseParty ID="16548426" InternalCasePartyID="1633585331" InternalPartyID="1614451562">
      <ObservedRace Word="W">White</ObservedRace>
      <ObservedEthnicity Word="NH">Non Hispanic</ObservedEthnicity>
      <Connection Word="PET" BaseConnection="PL" ID="34645653" InternalCasePartyConnectionID="1635192840">
      <Description>Petitioner</Description>
      </Connection>
      <CasePartyName Current="true" ID="9638953" InternalNameID="1615263003">
      <FormattedName>Petitioner, Richard S</FormattedName>
      </CasePartyName>
      </CaseParty>
      <CaseParty ID="16548378" InternalCasePartyID="1633585333" InternalPartyID="1614451515">
      <ObservedRace Word="W">White</ObservedRace>
      <ObservedEthnicity Word="R">Refused</ObservedEthnicity>
      <Connection Word="CHL" BaseConnection="WA" ID="34645655" InternalCasePartyConnectionID="1635192842">
      <Description>Child (Family/Juv)</Description>
      </Connection>
      <CasePartyName Current="true" ID="9638891" InternalNameID="1615262953">
         <FormattedName>Dickens, Little</FormattedName>
         </CasePartyName>
    </CaseParty>
   <CaseParty ID="16548427" InternalCasePartyID="1633585332" InternalPartyID="1614451563">
      <ObservedRace Word="W">White</ObservedRace>
      <ObservedEthnicity Word="H">Hispanic</ObservedEthnicity>
      <Connection Word="RSP" BaseConnection="DF" ID="34645654" InternalCasePartyConnectionID="1635192841">
         <Description>Respondent</Description>
      </Connection>
      <CasePartyName Current="true" ID="9638954" InternalNameID="1615263004">
         <FormattedName>Respondent, Richard S</FormattedName>
      </CasePartyName>
   </CaseParty>
</Case>
</Integration>
My xslt code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.dc.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0">
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
   <xsl:template name="ProtectionOrder">
      <ext:ProtectionOrder>
         <xsl:variable name="vProtectionOrderID">
            <xsl:value-of select="@InternalProtectionOrderID"/>
         </xsl:variable>
<!--Respondent Address-->
         <xsl:for-each select="RespondentAddresses/Address">
            <xsl:call-template name="Location"/>
         </xsl:for-each>
<!--ext:ProtectionOrderID-->
         <ext:ProtectionOrderID>
            <xsl:value-of select="ProtectionOrderNumber"/>
         </ext:ProtectionOrderID>
<!--Respondent-->
         <xsl:for-each select="RespondentPartyID">
            <xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID) and (Connection[(@Word='RSP') ])]">
               <xsl:for-each select="//Party[@InternalPartyID=current()/@InternalPartyID]">
                  <xsl:call-template name="Respondent">
                     <xsl:with-param name="pProtectionOrderID">
                        <xsl:value-of select="$vProtectionOrderID"/>
                     </xsl:with-param>
                  </xsl:call-template>
               </xsl:for-each>
            </xsl:for-each>
         </xsl:for-each>
      </ext:ProtectionOrder>
   </xsl:template>
<!--Respondent Template-->
   <xsl:template name="Respondent">
      <xsl:param name="pProtectionOrderID"/>
      <ext:Respondent>
         <nc:PersonEthnicityCode>
            <xsl:choose>
               <xsl:when test="//CaseParty[@ID=current()/@ID]/ObservedEthnicity/@Word='NH'">N</xsl:when>
               <xsl:otherwise>
                  <xsl:if test="//CaseParty/ObservedEthnicity[@Word!='R']">
                     <xsl:value-of select="//CaseParty/ObservedEthnicity/@Word"/>
                  </xsl:if>
               </xsl:otherwise>
            </xsl:choose>
         </nc:PersonEthnicityCode>
      </ext:Respondent>
      <ext:RespondentPresentAtHearingIndicator>
         <xsl:value-of select="/Integration/ProtectionOrder/MNProtectionOrderAdditional/IsRespondentPresent"/>
      </ext:RespondentPresentAtHearingIndicator>
   </xsl:template>
</xsl:stylesheet>
 
Old December 31st, 2014, 02:35 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by winkimjr2 View Post
I have xml code with several CaseParty. The problem is that, my xslt is displaying ObservedEthnicity for the first found CaseParty which is not a Respondent.
How do I change it to display the correct ObservedEthnicity for the Respondent?

Wrong output
Code:
<ext:Respondent>
	<nc:PersonEthnicityCode>N</nc:PersonEthnicityCode>
	<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true">1966-01-02</ext:PersonBirthDate>
	<ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="false">1966-02-02</ext:PersonBirthDate>
	<ext:PersonName ext:currentIndicator="true">
	<nc:PersonFullName>Respondent, Richard S</nc:PersonFullName>
	</ext:PersonName>
</ext:Respondent>

Here is my xml code
Code:
<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com">
<Case InternalID="1616760296" ID="11683548" xmlns:user="http://tylertechnologies.com">
   <CaseParty ID="16548426" InternalCasePartyID="1633585331" InternalPartyID="1614451562">
      <ObservedRace Word="W">White</ObservedRace>
      <ObservedEthnicity Word="NH">Non Hispanic</ObservedEthnicity>
      <Connection Word="PET" BaseConnection="PL" ID="34645653" InternalCasePartyConnectionID="1635192840">
      <Description>Petitioner</Description>
      </Connection>
      <CasePartyName Current="true" ID="9638953" InternalNameID="1615263003">
      <FormattedName>Petitioner, Richard S</FormattedName>
      </CasePartyName>
      </CaseParty>
      <CaseParty ID="16548378" InternalCasePartyID="1633585333" InternalPartyID="1614451515">
      <ObservedRace Word="W">White</ObservedRace>
      <ObservedEthnicity Word="R">Refused</ObservedEthnicity>
      <Connection Word="CHL" BaseConnection="WA" ID="34645655" InternalCasePartyConnectionID="1635192842">
      <Description>Child (Family/Juv)</Description>
      </Connection>
      <CasePartyName Current="true" ID="9638891" InternalNameID="1615262953">
         <FormattedName>Dickens, Little</FormattedName>
         </CasePartyName>
    </CaseParty>
   <CaseParty ID="16548427" InternalCasePartyID="1633585332" InternalPartyID="1614451563">
      <ObservedRace Word="W">White</ObservedRace>
      <ObservedEthnicity Word="H">Hispanic</ObservedEthnicity>
      <Connection Word="RSP" BaseConnection="DF" ID="34645654" InternalCasePartyConnectionID="1635192841">
         <Description>Respondent</Description>
      </Connection>
      <CasePartyName Current="true" ID="9638954" InternalNameID="1615263004">
         <FormattedName>Respondent, Richard S</FormattedName>
      </CasePartyName>
   </CaseParty>
</Case>
</Integration>
My xslt code
Code:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.dc.us/ProtectionOrderExtension/1.0" xmlns:nc="http://niem.gov/niem/niem-core/2.0">
   <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/>
   <xsl:template name="ProtectionOrder">
      <ext:ProtectionOrder>
         <xsl:variable name="vProtectionOrderID">
            <xsl:value-of select="@InternalProtectionOrderID"/>
         </xsl:variable>
<!--Respondent Address-->
         <xsl:for-each select="RespondentAddresses/Address">
            <xsl:call-template name="Location"/>
         </xsl:for-each>
<!--ext:ProtectionOrderID-->
         <ext:ProtectionOrderID>
            <xsl:value-of select="ProtectionOrderNumber"/>
         </ext:ProtectionOrderID>
<!--Respondent-->
         <xsl:for-each select="RespondentPartyID">
            <xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID) and (Connection[(@Word='RSP') ])]">
               <xsl:for-each select="//Party[@InternalPartyID=current()/@InternalPartyID]">
                  <xsl:call-template name="Respondent">
                     <xsl:with-param name="pProtectionOrderID">
                        <xsl:value-of select="$vProtectionOrderID"/>
                     </xsl:with-param>
                  </xsl:call-template>
               </xsl:for-each>
            </xsl:for-each>
         </xsl:for-each>
      </ext:ProtectionOrder>
   </xsl:template>
<!--Respondent Template-->
   <xsl:template name="Respondent">
      <xsl:param name="pProtectionOrderID"/>
      <ext:Respondent>
         <nc:PersonEthnicityCode>
            <xsl:choose>
               <xsl:when test="//CaseParty[@ID=current()/@ID]/ObservedEthnicity/@Word='NH'">N</xsl:when>
               <xsl:otherwise>
                  <xsl:if test="//CaseParty/ObservedEthnicity[@Word!='R']">
                     <xsl:value-of select="//CaseParty/ObservedEthnicity/@Word"/>
                  </xsl:if>
               </xsl:otherwise>
            </xsl:choose>
         </nc:PersonEthnicityCode>
      </ext:Respondent>
      <ext:RespondentPresentAtHearingIndicator>
         <xsl:value-of select="/Integration/ProtectionOrder/MNProtectionOrderAdditional/IsRespondentPresent"/>
      </ext:RespondentPresentAtHearingIndicator>
   </xsl:template>
</xsl:stylesheet>
I resolved this one





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 with puthex help humanic Assembly Language 1 January 10th, 2010 07:14 AM
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.