title: I want to display the first petition only when there is more than one in xml document
body: <p>I have a xml with 2 petitioners where petitioner = true. I only want to display the first one even when if there is more than one. How do I do this? 
  I am using a template for the petitioner which I have added here below.</p>
  
  <p><strong>Desired output is only one petition like this</strong></p>
  
  <pre><code>&lt;ext:ProtectedParty&gt;
          &lt;ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true"&gt;1969-08-06&lt;/ext:PersonBirthDate&gt;
          &lt;nc:PersonName&gt;
              &lt;nc:PersonGivenName&gt;MARY&lt;/nc:PersonGivenName&gt;
              &lt;nc:PersonMiddleName/&gt;
              &lt;nc:PersonSurName&gt;TESTER&lt;/nc:PersonSurName&gt;
              &lt;nc:PersonNameSuffixText/&gt;
              &lt;nc:PersonFullName&gt;TESTER, MARY&lt;/nc:PersonFullName&gt;
          &lt;/nc:PersonName&gt;
          &lt;ext:PersonRaceCode/&gt;
          &lt;nc:PersonSexCode&gt;F &lt;/nc:PersonSexCode&gt;
          &lt;ext:PetitionerIndicator&gt;true&lt;/ext:PetitionerIndicator&gt;
      &lt;/ext:ProtectedParty&gt;
      &lt;ext:ProtectedParty&gt;
          &lt;ext:PersonBirthDate ext:approximateDateIndicator="false" ext:currentIndicator="true"&gt;2012-08-16&lt;/ext:PersonBirthDate&gt;
          &lt;nc:PersonName&gt;
              &lt;nc:PersonGivenName&gt;Baby&lt;/nc:PersonGivenName&gt;
              &lt;nc:PersonMiddleName/&gt;
              &lt;nc:PersonSurName&gt;Tester&lt;/nc:PersonSurName&gt;
              &lt;nc:PersonNameSuffixText/&gt;
              &lt;nc:PersonFullName&gt;Tester, Baby&lt;/nc:PersonFullName&gt;
          &lt;/nc:PersonName&gt;
          &lt;ext:PersonRaceCode/&gt;
          &lt;nc:PersonSexCode&gt;F &lt;/nc:PersonSexCode&gt;
          &lt;ext:PetitionerIndicator&gt;false&lt;/ext:PetitionerIndicator&gt;
      &lt;/ext:ProtectedParty&gt;
  </code></pre>
  
  <p><strong>My xml document</strong></p>
  
  <pre><code>&lt;ProtectionOrderParties&gt;
  &lt;ProtectionOrderParty InternalPartyID="77"&gt;
      &lt;ProtectionOrderPartyNames&gt;
          &lt;ProtectionOrderPartyName Current="true" InternalNameID="77" FormattedName="Marko, Keem"/&gt;
      &lt;/ProtectionOrderPartyNames&gt;
      &lt;ProtectionOrderConnection&gt;
          &lt;Petitioner&gt;true&lt;/Petitioner&gt;
          &lt;ProtectedParty&gt;true&lt;/ProtectedParty&gt;
      &lt;/ProtectionOrderConnection&gt;
  &lt;/ProtectionOrderParty&gt;
  &lt;ProtectionOrderParty InternalPartyID="97"&gt;
      &lt;ProtectionOrderPartyNames&gt;
          &lt;ProtectionOrderPartyName Current="true" InternalNameID="53" FormattedName="JoAnn, Nenni"/&gt;
      &lt;/ProtectionOrderPartyNames&gt;
      &lt;ProtectionOrderConnection&gt;
          &lt;Petitioner&gt;true&lt;/Petitioner&gt;
          &lt;ProtectedParty&gt;true&lt;/ProtectedParty&gt;
      &lt;/ProtectionOrderConnection&gt;
  &lt;/ProtectionOrderParty&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>My xslt code</strong></p>
  
  <pre><code>       &lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;xsl:stylesheet version="3.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ext="http://www.courts.state.mn.us/ProtectionOrderExtension/1.0" exclude-result-prefixes="mscef msxsl exsl"&gt;
  &lt;xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes"/&gt;
  &lt;xsl:template name="ProtectionOrder"&gt;
      &lt;ext:ProtectionOrder&gt;
      &lt;xsl:variable name="vProtectionOrderID"&gt;
      &lt;xsl:value-of select="@InternalProtectionOrderID"/&gt;
      &lt;/xsl:variable&gt;
  &lt;!--Petitioner's Address--&gt;
  &lt;xsl:for-each select="ProtectionOrderParties/ProtectionOrderParty[(ProtectionOrderConnection/Petitioner='true') and (ProtectionOrderConnection/ProtectedParty='false')][1]"&gt;
      &lt;xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID) and (Connection[(@Word='PET') and (not(RemovedReason))])][1]"&gt;
      &lt;xsl:for-each select="//Party[@InternalPartyID=current()/@InternalPartyID]/Address"&gt;
      &lt;xsl:call-template name="Location"/&gt;
      &lt;/xsl:for-each&gt;
      &lt;/xsl:for-each&gt;
      &lt;/xsl:for-each&gt;
  &lt;!--Petitioner--&gt;
      &lt;xsl:for-each select="ProtectionOrderParties/ProtectionOrderParty[(ProtectionOrderConnection/Petitioner='true') and (ProtectionOrderConnection/ProtectedParty='false')][1]"&gt;
      &lt;xsl:for-each select="/Integration/Party[@InternalPartyID=current()/@InternalPartyID]"&gt;
      &lt;xsl:call-template name="Petitioner"/&gt;
      &lt;/xsl:for-each&gt;
      &lt;/xsl:for-each&gt;
  &lt;!--Protected Party--&gt;
      &lt;xsl:for-each select="ProtectionOrderParties/ProtectionOrderParty[ProtectionOrderConnection/ProtectedParty='true']"&gt;
      &lt;xsl:variable name="vPetitionerIndicator"&gt;
      &lt;xsl:value-of select="ProtectionOrderConnection/Petitioner"/&gt;
      &lt;/xsl:variable&gt;
      &lt;xsl:for-each select="//CaseParty[(@InternalPartyID=current()/@InternalPartyID)]"&gt;
      &lt;xsl:for-each select="/Integration/Party[@InternalPartyID=current()/@InternalPartyID]"&gt;
      &lt;xsl:call-template name="ProtectedParty"&gt;
      &lt;xsl:with-param name="pPetionerIndicator"&gt;
      &lt;xsl:value-of select="$vPetitionerIndicator"/&gt;
      &lt;/xsl:with-param&gt;
      &lt;/xsl:call-template&gt;
      &lt;/xsl:for-each&gt;
      &lt;/xsl:for-each&gt;
      &lt;/xsl:for-each&gt;
      &lt;/xsl:template&gt;
  &lt;!--Petitioner Template--&gt;
      &lt;xsl:template name="Petitioner"&gt;
      &lt;ext:Petitioner&gt;
      &lt;ext:AddressReference&gt;
      &lt;xsl:for-each select="Address[@PartyCurrent='true']"&gt;
      &lt;xsl:attribute name="ext:currentIndicator"&gt;&lt;xsl:value-of select="@PartyCurrent"/&gt;&lt;/xsl:attribute&gt;
      &lt;nc:LocationReference&gt;
      &lt;xsl:attribute name="s:ref"&gt;&lt;xsl:text&gt;INT&lt;/xsl:text&gt;&lt;xsl:value-of select="@ID"/&gt;&lt;/xsl:attribute&gt;
      &lt;/nc:LocationReference&gt;
      &lt;/xsl:for-each&gt;
      &lt;/ext:AddressReference&gt;
      &lt;ext:PersonBirthDate&gt;
      &lt;xsl:choose&gt;
      &lt;xsl:when test="DateOfBirth[@Current='true']"&gt;
      &lt;xsl:attribute name="ext:approximateDateIndicator"&gt;false&lt;/xsl:attribute&gt;
      &lt;xsl:attribute name="ext:currentIndicator"&gt;true&lt;/xsl:attribute&gt;
      &lt;xsl:value-of select="mscef:formatDate(string(DateOfBirth[@Current='true']))"/&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:when test="ApproximateDOB"&gt;
      &lt;xsl:attribute name="ext:approximateDateIndicator"&gt;true&lt;/xsl:attribute&gt;
      &lt;xsl:attribute name="ext:currentIndicator"&gt;true&lt;/xsl:attribute&gt;
      &lt;xsl:value-of select="mscef:formatDate(string(ApproximateDOB))"/&gt;
      &lt;/xsl:when&gt;
      &lt;/xsl:choose&gt;
      &lt;/ext:PersonBirthDate&gt;
      &lt;nc:PersonName&gt;
      &lt;nc:PersonGivenName&gt;
      &lt;xsl:value-of select="PartyName/NameFirst"/&gt;
      &lt;/nc:PersonGivenName&gt;
      &lt;nc:PersonMiddleName&gt;
      &lt;xsl:value-of select="PartyName/NameMiddle"/&gt;
      &lt;/nc:PersonMiddleName&gt;
      &lt;nc:PersonSurName&gt;
      &lt;xsl:value-of select="PartyName/NameLast"/&gt;
      &lt;/nc:PersonSurName&gt;
      &lt;nc:PersonNameSuffixText&gt;
      &lt;xsl:value-of select="PartyName/NameSuffix"/&gt;
      &lt;/nc:PersonNameSuffixText&gt;
      &lt;nc:PersonFullName&gt;
      &lt;xsl:value-of select="PartyName/FormattedName"/&gt;
      &lt;/nc:PersonFullName&gt;
      &lt;/nc:PersonName&gt;
      &lt;ext:PersonRaceCode&gt;
      &lt;!--&lt;xsl:value-of select="CaseParty/ObservedRace/@Word"/&gt;--&gt;
      &lt;xsl:value-of select="//Case/CaseParty[@InternalPartyID=current()/@InternalPartyID]/ObservedRace/@Word"/&gt;
      &lt;/ext:PersonRaceCode&gt;
      &lt;nc:PersonSexCode&gt;
      &lt;xsl:value-of select="Party/Gender/@Word"/&gt;
      &lt;/nc:PersonSexCode&gt;
      &lt;/ext:Petitioner&gt;
      &lt;/xsl:template&gt;
  &lt;!--Protected Party Template--&gt;
      &lt;xsl:template name="ProtectedParty"&gt;
      &lt;xsl:param name="pPetionerIndicator"/&gt;
      &lt;ext:ProtectedParty&gt;
      &lt;ext:PersonBirthDate&gt;
      &lt;xsl:choose&gt;
      &lt;xsl:when test="DateOfBirth[@Current='true']"&gt;
      &lt;xsl:attribute name="ext:approximateDateIndicator"&gt;false&lt;/xsl:attribute&gt;
      &lt;xsl:attribute name="ext:currentIndicator"&gt;true&lt;/xsl:attribute&gt;
      &lt;xsl:value-of select="mscef:formatDate(string(DateOfBirth[@Current='true']))"/&gt;
      &lt;/xsl:when&gt;
      &lt;xsl:when test="ApproximateDOB"&gt;
      &lt;xsl:attribute name="ext:approximateDateIndicator"&gt;true&lt;/xsl:attribute&gt;
      &lt;xsl:attribute name="ext:currentIndicator"&gt;true&lt;/xsl:attribute&gt;
      &lt;xsl:value-of select="mscef:formatDate(string(ApproximateDOB))"/&gt;
      &lt;/xsl:when&gt;
      &lt;/xsl:choose&gt;
      &lt;/ext:PersonBirthDate&gt;
      &lt;xsl:for-each select="PartyName[@Current='true']"&gt;
      &lt;nc:PersonName&gt;
      &lt;nc:PersonGivenName&gt;
      &lt;xsl:value-of select="NameFirst"/&gt;
      &lt;/nc:PersonGivenName&gt;
      &lt;nc:PersonMiddleName&gt;
      &lt;xsl:value-of select="NameMiddle"/&gt;
      &lt;/nc:PersonMiddleName&gt;
      &lt;nc:PersonSurName&gt;
      &lt;xsl:value-of select="NameLast"/&gt;
      &lt;/nc:PersonSurName&gt;
      &lt;nc:PersonNameSuffixText&gt;
      &lt;xsl:value-of select="NameSuffix"/&gt;
      &lt;/nc:PersonNameSuffixText&gt;
      &lt;nc:PersonFullName&gt;
      &lt;xsl:value-of select="FormattedName"/&gt;
      &lt;/nc:PersonFullName&gt;
  &lt;/nc:PersonName&gt;
  &lt;/xsl:for-each&gt;
  &lt;ext:PersonRaceCode&gt;
  &lt;!--&lt;xsl:value-of select="//CaseParty/ObservedRace/@Word"/&gt;--&gt;
  &lt;xsl:value-of select="//Case/CaseParty[@InternalPartyID=current()/@InternalPartyID]/ObservedRace/@Word"/&gt;
  &lt;/ext:PersonRaceCode&gt;
  &lt;nc:PersonSexCode&gt;
  &lt;xsl:value-of select="Gender/@Word"/&gt;
  &lt;/nc:PersonSexCode&gt;
  &lt;ext:PetitionerIndicator&gt;
  &lt;xsl:value-of select="$pPetionerIndicator"/&gt;
  &lt;/ext:PetitionerIndicator&gt;
  &lt;/ext:ProtectedParty&gt;
      &lt;/xsl:template&gt;
  &lt;!--Template for DateOfBirth for the respondent--&gt;
      &lt;xsl:template match="DateOfBirth"&gt;
  &lt;ext:PersonBirthDate&gt;
  &lt;xsl:attribute name="ext:approximateDateIndicator"&gt;false&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="ext:currentIndicator"&gt;false&lt;/xsl:attribute&gt;
  &lt;xsl:value-of select="mscef:formatDate(string(.))"/&gt;
          &lt;/ext:PersonBirthDate&gt;
      &lt;/xsl:template&gt;
  &lt;!--Template for DateOfBirth or the respondent where Current = true--&gt;
      &lt;xsl:template match="DateOfBirth[@Current='true']"&gt;
  &lt;ext:PersonBirthDate&gt;
  &lt;xsl:attribute name="ext:approximateDateIndicator"&gt;false&lt;/xsl:attribute&gt;
  &lt;xsl:attribute name="ext:currentIndicator"&gt;true&lt;/xsl:attribute&gt;
  &lt;xsl:value-of select="mscef:formatDate(string(.))"/&gt;
  &lt;/ext:PersonBirthDate&gt;
      &lt;/xsl:template&gt;
  &lt;!--Template for ApproximateDOB--&gt;
      &lt;xsl:template match="ApproximateDOB"&gt;
      &lt;ext:PersonBirthDate ext:approximateDateIndicator="true" ext:currentIndicator="{not(../DateOfBirth)}"&gt;
      &lt;xsl:value-of select="mscef:formatDate(string(.))"/&gt;
      &lt;/ext:PersonBirthDate&gt;
      &lt;/xsl:template&gt;
  &lt;/ext:Respondent&gt;
  &lt;/xsl:template&gt;
  &lt;/xsl:stylesheet&gt;
  </code></pre>