Jump to content
Sign in to follow this  
winkimjr2

I do not want a coma to appear

Recommended Posts

In my schema I have AddressLine1, AddressLine2, AddressLine3 and AddressLine4. When address is added to each AddressLine a comma is inserted to separate the AddressLines. However if only AddressLine1 and AddressLine2 have address, then there should not be a comma after the AddressLine2 because there is nothing else after it.My output is showing a trailing comma after AddressLine2 (Sydney Australia 123456A,) even though it should not.

Output472 Case Ave, Apt 2, Saint Paul, MN, 55106; 123 Beautiful Ocean, Sydney Australia 123456A,

 

My xml

<Address InternalAddressID="1618212014" Type="Foreign">	<Location Word="OTHER">Other</Location>	<AddressLine1>123 Beautiful Ocean</AddressLine1>	<AddressLine2>Sydney Australia 123456A</AddressLine2>	<Foreign>true</Foreign></Address>

My Xslt Code

<!--Foreign Address-->

<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>
Edited by winkimjr2

Share this post


Link to post
Share on other sites

Try putting the comma before the element instead of after, like this:

<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:if>        <xsl:if test="AddressLine2">            <xsl:text>, </xsl:text>            <xsl:value-of select="AddressLine2"/>        </xsl:if>        <xsl:if test="AddressLine3">            <xsl:text>, </xsl:text>            <xsl:value-of select="AddressLine3"/>        </xsl:if>        <xsl:if test="AddressLine4">            <xsl:text>, </xsl:text>            <xsl:value-of select="AddressLine4"/>        </xsl:if>        <xsl:text>; </xsl:text>    </xsl:for-each></xsl:for-each>
  • Like 1

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
Sign in to follow this  

×
×
  • Create New...