Jump to content

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
Link to comment
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
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Create New...