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 October 17th, 2014, 01:39 PM
Friend of Wrox
 
Join Date: Apr 2013
Posts: 101
Thanks: 14
Thanked 0 Times in 0 Posts
Default How do I display two elements from nodes? Sounds easy but its NOT

I would like to use XSLT to display Conditions and Findings. I would like to check For each Finding or Condition node to determine if there is one or more related parties for the finding or condition being processed. If there are parties related to the finding or condition, a <Parties> structure will be represented as a child of <Findings> or as a child of <Condition>.

1. Im my xml under Findings, I have a finding with 2 related parties shown by the 2 Party internalPartyIDs. If there are NO parties related to the finding or condition, the <Parties> structure will NOT be shown. For each instance of <Party> for the Finding or Condition, I want to find <ProtectionOrderParty> node that has a value in its InternalPartyID attribute that matches the value in the InternalPartyID attribute of the <Party> element that is a child of Findings and Conditions.

Then I want to append the value from the FormattedName attribute of the ProtectionOrderPArtyName element where the Current attribute has a value of true to the end of the Findings and Conditions text.

An example of what I want for the <ext:FindingText> element look like with 2 related parties:

<ext:FindingText> The following parties need an order for protection and are referred to in this Order as "Protected Person(s)": Flintstone, Bam Bam; Noir, Flintstone, Wilma Ann</ext:FindingText>

2. Determine if there is one or more related addresses for the condition being processed. If there are addresses related to the condition, an <Addresses> structure will show as a child of <Condition>. For the xml I posted here, the result should look like this:

<ext:CondtionText> Respondent must not go to or enter the residence(s) of the Protected Person(s) located at the address(es) listed below. And Respondent must stay a reasonable distance away from the residence(s) of the Protected Person(s) specifically as follows (500 feet); And Respondent must stay a reasonable distance away from ANY FUTURE RESIDENCES of the Protected Person(s): 987 W Jump ALY W, Funny, MN, 55401; DAYCARE, 234 rock ALY, Funny, MN, 55432<ext:ConditionText>

My XSLT Condition Code
Code:
<xsl:for-each select="MNProtectionOrderAdditional/Conditions/Condition">
  <ext:ProtectionOrderCondition>
    <ext:ConditionText>
      <xsl:value-of select="Description"/>
   </ext:ConditionText>
   <ext:ConditionCode>
     <xsl:value-of select="document(concat($gEnvPath,'\ConfigFiles\MNCISCodes\ProtectionOrderConditionCodeMapping.xml'))
   /ProtectionOrderConditionCodeMapping/Mapping[MNCISCode=current()/Condition/@Word]/BCACode"/>
  </ext:ConditionCode>
</ext:ProtectionOrderCondition>
</xsl:for-each>
My Findings XSLT code
Code:
<xsl:for-each select="MNProtectionOrderAdditional/Findings/Finding">
   <ext:ProtectionOrderFinding>
     <ext:FindingText>
   <xsl:value-of select="Description"/>
     </ext:FindingText>
   <ext:FindingCode>
   <xsl:value-of select="Finding/@Word"/>
    </ext:FindingCode>
</ext:ProtectionOrderFinding>
</xsl:for-each>
My XML document
Code:
<Integration>
  <ProtectionOrder InternalProtectionOrderID="220" xmlns:user="http://tylertechnologies.com">
    <Deleted>false</Deleted>
    <RespondentPartyID InternalPartyID="1614450883">1614450883</RespondentPartyID>
    <RespondentNameID InternalNameID="1615262284">1615262284</RespondentNameID>
    <RespondentAddresses>
   <Address InternalAddressID="1618209023">
   <Confidential>false</Confidential>
   <AddressLine2>987 W Jump ALY W</AddressLine2>
   <AddressLine4>Funny, MN, 55401</AddressLine4>
   <Block>987</Block>
   <Street>Rubble</Street>
   <City>Funny</City>
   <State>MN</State>
   <Zip>55401</Zip>
   <Foreign>false</Foreign>
        </Address>
    </RespondentAddresses>
    <ProtectionOrderNumber>1400220</ProtectionOrderNumber>
   <ProtectionOrderParties>
          <ProtectionOrderParty InternalPartyID="1614450886">
   <ProtectionOrderPartyNames>
     <ProtectionOrderPartyName Current="true" InternalNameID="1615262287" FormattedName="Flintstone, Bam Bam"/>
     </ProtectionOrderPartyNames>
     <ProtectionOrderConnection>
     <Petitioner>false</Petitioner>
     <ProtectedParty>true</ProtectedParty>
     </ProtectionOrderConnection>
     </ProtectionOrderParty>
     <ProtectionOrderParty InternalPartyID="1614450882">
     <ProtectionOrderPartyNames>
     <ProtectionOrderPartyName Current="true" InternalNameID="1615262283" FormattedName="Flintstone, Wilma Ann"/>
   </ProtectionOrderPartyNames>
   <ProtectionOrderConnection>
   <Petitioner>true</Petitioner>
 </ProtectionOrderConnection>
 <MNProtectionOrderPartyAdditional xmlns:fn="http://www.w3.org/2005/xpath-functions">
   <ProtectedAddresses>
     <Address InternalAddressID="1618207867" Type="Standard">
     <Location Word="HOME">Home</Location>
     <Confidential>false</Confidential>
     <AddressLine2>987 W Jump ALY W</AddressLine2>
     <AddressLine4>Funny, MN, 55401</AddressLine4>
     <Block>987</Block>
     <PreDir Word="E">East</PreDir>
     <Street>Jump</Street>
     <AddrSfxKy Word="ALY">Alley</AddrSfxKy>
     <PostDir Word="W">West</PostDir>
     <City>Funny</City>
     <State>MN</State>
     <Zip>55401</Zip>
     <Foreign>false</Foreign>
     </Address>
     <Address InternalAddressID="1618209015" Type="Standard">
     <Location Word="DAYCARE">Daycare</Location>
     <Confidential>false</Confidential>
     <AddressLine2>234 rock ALY</AddressLine2>
     <AddressLine4>Funny, MN, 55432</AddressLine4>
     <Block>234</Block>
     <Street>rock</Street>
     <AddrSfxKy Word="ALY">Alley</AddrSfxKy>
     <City>Funny</City>
     <State>MN</State>
     <Zip>55432</Zip>
     <Foreign>false</Foreign>
     </Address>
  </ProtectedAddresses>
</MNProtectionOrderPartyAdditional>
  </ProtectionOrderParty>
</ProtectionOrderParties>
<MNProtectionOrderAdditional InternalID="220" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<IsForeignOrder>false</IsForeignOrder>
<Findings>
  <Finding>
    <Finding Word="EXP2">02 An Order For Protection is needed</Finding>
<Description>The following parties need an order for protection and are referred to in this Order as "Protected Person(s)":</Description>
<Parties>
  <Party InternalPartyID="1614450886"/>
  <Party InternalPartyID="1614450882"/>
</Parties>
</Finding>
</Findings>
<Conditions>   
   <Condition>
    <Condition Word="03C1EXPC">03.C.1 Respondent must not enter the residence</Condition>
               <Description>Respondent must not go to or enter the residence(s) of the Protected Person(s) located (see below); And Respondent must stay a reasonable distance away from the residence(s) of the Protected Person(s) specifically as follows (distance); And Respondent must stay a reasonable distance away from ANY FUTURE RESIDENCES of the Protected Person(s).</Description>
  <Address InternalAddressID="1618207867"/>
  </Condition>
</Conditions>
</MNProtectionOrderAdditional>
</ProtectionOrder>
</Integration>





Similar Threads
Thread Thread Starter Forum Replies Last Post
removing duplicate elements and collecting all sub nodes together john007 XSLT 1 March 9th, 2012 05:09 PM
Mirge Multiple nodes with sons elements Ahly_Bayern XSLT 1 March 24th, 2011 07:40 AM
Appending set of elements after the similar nodes sesath XSLT 2 May 15th, 2007 10:16 AM
Grouping orphan nodes to paranet elements ROCXY XSLT 2 January 1st, 2006 07:11 AM
HOW TO: Display specified # of nodes kwilliams XSLT 2 October 5th, 2005 11:04 AM





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