How do I remove a semi colon when I have only one party in x
Posted: Tue Dec 30, 2014 1:28 am
I would like to display a name followed by address and a semi colon and another name followed by address when xml document has 2 parties in the conditions element. My output is displaying the names with a semi colon and then the address. I would like to display a name followed by its associated address and then a semi colon and then the second name and its address.
Also when my xml document has only one name in the conditions element, a semi colon is added at the end which I do not want.
How do I change me xslt to only add a semi colon after the first name and its address and not add a semi colon when there is only one name in the conditions element?
My xml document
My xslt code for the conditions
Also when my xml document has only one name in the conditions element, a semi colon is added at the end which I do not want.
How do I change me xslt to only add a semi colon after the first name and its address and not add a semi colon when there is only one name in the conditions element?
My xml document
Code: Select all
<ProtectionOrder Op="E" InternalProtectionOrderID="2571" xmlns:user="http://tylertechnologies.com">
<ProtectionOrderParties>
<ProtectionOrderParty InternalPartyID="1614451562">
<ProtectionOrderPartyNames>
<ProtectionOrderPartyName Current="true" InternalNameID="1615263003" FormattedName="Petitioner, Richard S"/>
</ProtectionOrderPartyNames>
<ProtectionOrderConnection>
<Petitioner>true</Petitioner>
<ProtectedParty>true</ProtectedParty>
</ProtectionOrderConnection>
<MNProtectionOrderPartyAdditional xmlns:fn="http://www.w3.org/2005/xpath-functions">
<ProtectedAddresses>
<Address InternalAddressID="1618211271" Type="Standard">
<Location Word="HOME">Home</Location>
<Confidential>false</Confidential>
<AddressLine2>3 Back Petitioner ST</AddressLine2>
<AddressLine4>My Town, MN, 55555</AddressLine4>
<Block>3</Block>
<Street>Back Petitioner</Street>
<AddrSfxKy Word="ST">Street</AddrSfxKy>
<City>My Town</City>
<State>MN</State>
<Zip>55555</Zip>
<Foreign>false</Foreign>
</Address>
</ProtectedAddresses>
</MNProtectionOrderPartyAdditional>
</ProtectionOrderParty>
<ProtectionOrderParty InternalPartyID="1614451515">
<ProtectionOrderPartyNames>
<ProtectionOrderPartyName Current="true" InternalNameID="1615262953" FormattedName="Dickens, Little"/>
</ProtectionOrderPartyNames>
<ProtectionOrderConnection>
<Petitioner>false</Petitioner>
<FilingParty>false</FilingParty>
<ProtectedParty>true</ProtectedParty>
<Minor>true</Minor>
</ProtectionOrderConnection>
<MNProtectionOrderPartyAdditional xmlns:fn="http://www.w3.org/2005/xpath-functions">
<ProtectedAddresses>
<Address InternalAddressID="1618211278" Type="Foreign">
<Location Word="DAYCARE">Daycare</Location>
<Confidential>false</Confidential>
<AddressLine1>Foreign Address</AddressLine1>
<AddressLine2>FA line 2</AddressLine2>
<AddressLine3>FA line 3</AddressLine3>
<AddressLine4>FA line 4</AddressLine4>
<Foreign>true</Foreign>
</Address>
</ProtectedAddresses>
</MNProtectionOrderPartyAdditional>
</ProtectionOrderParty>
</ProtectionOrderParties>
<MNProtectionOrderAdditional InternalID="2567" xmlns:fn="http://www.w3.org/2005/xpath-functions">
<Conditions>
<Condition>
<Code Word="03AEXPC">03.A Respondent must not commit domestic abuse</Code>
<Description>Respondent must not commit acts of domestic abuse against the Protected Person(s). </Description>
</Condition>
<Condition>
<Code Word="03F1EXPC">03.F.1 Respondent must not call/enter place of employment</Code> <Description>Respondent must not call or enter the place of employment of the following party(ies). This includes all land, parking lots, and buildings of the following addresses:</Description>
<Parties>
<Party InternalPartyID="1614451562"/>
<Party InternalPartyID="1614451515"/>
</Parties>
<Addresses>
<Address InternalAddressID="1618211271"/>
<Address InternalAddressID="1618211278"/>
</Addresses>
</Condition>
</Conditions>
</MNProtectionOrderAdditional>
</ProtectionOrder>
Code: Select all
<!--ext:ProtectionOrderCondition-->
<xsl:for-each select="MNProtectionOrderAdditional/Conditions/Condition">
<ext:ProtectionOrderCondition>
<ext:ConditionText>
<xsl:variable name="vCondition">
<xsl:value-of select="normalize-space(Description)"/>
<xsl:text> </xsl:text>
<xsl:for-each select="Parties/Party">
<xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty[@InternalPartyID=current()/@InternalPartyID]">
<xsl:value-of select="ProtectionOrderPartyNames/ProtectionOrderPartyName[@Current='true']/@FormattedName"/>
<!--<xsl:text>; </xsl:text>-->
<xsl:if test="position() != last()">
<xsl:text>; </xsl:text>
</xsl:if>
</xsl:for-each>
</xsl:for-each>
<xsl:text> </xsl:text>
<xsl:for-each select="Addresses/Address">
<xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty/MNProtectionOrderPartyAdditional/ProtectedAddresses/Address[@InternalAddressID=current()/@InternalAddressID]">
<xsl:if test="AddressLine1">
<xsl:value-of select="AddressLine1"/>
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="AddressLine2">
<xsl:value-of select="AddressLine2"/>
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="AddressLine3">
<xsl:value-of select="AddressLine3"/>
<xsl:text>, </xsl:text>
</xsl:if>
<xsl:if test="AddressLine4">
<xsl:value-of select="AddressLine4"/>
</xsl:if>
<xsl:text>; </xsl:text>
</xsl:for-each>
</xsl:for-each>
</xsl:variable>
<xsl:choose>
<xsl:when test="substring($vCondition,string-length($vCondition)-1,2)='; '">
<xsl:value-of select="substring($vCondition,1,string-length($vCondition)-2)"/>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$vCondition"/>
</xsl:otherwise>
</xsl:choose>
</ext:ConditionText>
<ext:ConditionCode>
<xsl:value-of select="document(concat($gEnvPath,'\ConfigFiles\MNCISCodes\ProtectionOrderConditionCodeMapping.xml'))
/ProtectionOrderConditionCodeMapping/Mapping[MNCISCode=current()/Code/@Word]/BCACode"/>
</ext:ConditionCode>
</ext:ProtectionOrderCondition>
</xsl:for-each>