winkimjr2 0 Report post Posted February 27, 2015 (edited) 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 February 27, 2015 by winkimjr2 Quote Share this post Link to post Share on other sites
Ingolme 971 Report post Posted February 28, 2015 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> 1 Quote Share this post Link to post Share on other sites
winkimjr2 0 Report post Posted March 2, 2015 Thank you Foxy Mod. This solution worked! Quote Share this post Link to post Share on other sites