How do I output 2 nodes with their children?

Questions about XML that are not covered by the other forums should go here.
winkimjr2
Posts: 53

How do I output 2 nodes with their children?

Thu Oct 06, 2016 5:17 pm

I am using a template to output NotificationEvent. My xml has 2 NotificationEvents. The problem is that I am not getting correct output

Expected output

Code: Select all

<IntegrationConditions>
   <IntegrationCondition Word="CASEDETAIL" Description="CaseDetail/Security">
      <NotificationEvent notificationType="CaseDetailsNotification" elementState="Existing" elementName="Case" elementKey="14886023">CaseTitleModified</NotificationEvent>
   </IntegrationCondition>
   <IntegrationCondition Word="SUBPARTY" Description="SubjectParty">
      <NotificationEvent notificationType="SubjectPartyNotification" elementState="Existing" elementName="CaseRespondent" elementKey="18118912">SubjectPartyNameAdded</NotificationEvent>
   </IntegrationCondition>
</IntegrationConditions>


xml document

Code: Select all

<Integration>
   <ControlPoint>SAVE-FAM-CASE</ControlPoint>
   <Case ID="14886023" Op="E" xmlns:user="http://tylertechnologies.com">
      <CaseCategory>FAM</CaseCategory>
      <CaseType Word="DMA">Domestic Abuse</CaseType>
      <BaseCaseType>Civil Domestic Violence</BaseCaseType>
      <CaseTitle Op="E">In the Matter</CaseTitle>
      <CaseNumber>370</CaseNumber>


      <CaseParty Op="E" ID="18118912" InternalCasePartyID="1649118185" InternalPartyID="1617896624">
         <Connection Word="RSP" BaseConnection="DF" ID="44925838" InternalCasePartyConnectionID="1651131186">
            <Description>Respondent</Description>
         </Connection>
         <CasePartyName ID="12124296" InternalNameID="1618924116">
            <NameFirst>SILLY</NameFirst>
            <NameLast>SOLLY</NameLast>
            <FormattedName>SOLLY, SILLY</FormattedName>
         </CasePartyName>
         <CasePartyName Op="A" Current="true" ID="12124639" InternalNameID="1618924395">
            <CasePartyNameType Op="A" Word=""/>
            <NameMiddle>Soo</NameMiddle>
            <FormattedName>Solly, Silly Soo</FormattedName>
         </CasePartyName>
      </CaseParty>

   <IntegrationConditions>
      <IntegrationCondition Word="CASEDETAIL" Description="CaseDetail/Security">
         <NotificationEvent notificationType="CaseDetailsNotification" elementState="Existing" elementName="Case" elementKey="14886023">CaseTitleModified</NotificationEvent>
      </IntegrationCondition>
      <IntegrationCondition Word="SUBPARTY" Description="SubjectParty">
         <NotificationEvent notificationType="SubjectPartyNotification" elementState="Existing" elementName="CaseRespondent" elementKey="18118912">SubjectPartyNameAdded</NotificationEvent>
      </IntegrationCondition>
   </IntegrationConditions>
</Integration>



My xslt code with template

Code: Select all

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet>
   <xsl:template name="CaseDetailsNotification">
      <xsl:if test="Integration/ControlPoint='SAVE-FAM-CASE'">
         <xsl:if test="Integration/Case/CaseType/@Word='DMA'">
            <xsl:for-each select="Integration/Case[@Op='E']">/Integration/IntegrationConditions/IntegrationCondition[2]/NotificationEvent/@notificationType
            <NotificationEvent notificationType="CaseDetailsNotification">
                  <xsl:attribute name="elementState"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementState"/></xsl:attribute>
                  <xsl:attribute name="elementName"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementName"/></xsl:attribute>
                  <xsl:attribute name="elementKey"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementKey"/></xsl:attribute>
                  <xsl:choose>
                     <xsl:when test="/Integration/Case/@Op='E'">CaseTitleModified</xsl:when>
                  </xsl:choose>
               </NotificationEvent>
            </xsl:for-each>
         </xsl:if>
      </xsl:if>
      <!-- Check PartyName change-->
      <xsl:if test="Integration/Case/CaseType/@Word='DMA'">
         <xsl:for-each select="/Integration/Case/CaseParty[@Op='E']">
            <NotificationEvent notificationType="CaseDetailsNotification">
               <xsl:attribute name="elementState"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementState"/></xsl:attribute>
               <xsl:attribute name="elementName"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementName"/></xsl:attribute>
               <xsl:attribute name="elementKey"><xsl:value-of select="/Integration/IntegrationConditions/IntegrationCondition/NotificationEvent/@elementKey"/></xsl:attribute>
               <xsl:choose>
                  <xsl:when test="/Integration/Case/CaseParty/@Op='E'">SubjectPartyNameAdded</xsl:when>
               </xsl:choose>
            </NotificationEvent>
         </xsl:for-each>
      </xsl:if>
   </xsl:template>
</xsl:stylesheet>
winkimjr2
Posts: 53

Re: How do I output 2 nodes with their children?

Thu Oct 06, 2016 6:25 pm

I do not need help for this........Thanks

Return to “General XML Questions”

Who is online

Users browsing this forum: Frankzorry and 1 guest