IMPORTANT:
this is not a Support Forum! Experienced users might answer from time to time questions posted here. If you need a professional and reliable answer, or if you want to report a bug, please contact Altova Support instead.

Profile: momokesh
About
User Name: momokesh
Forum Rank: Newbie
Real Name:
Location WI
Occupation:
Interests:
Gender: None Specified
Statistics
Joined: Friday, February 27, 2015
Last Visit: Tuesday, March 3, 2015 4:23:25 PM
Number of Posts: 2
[0.01% of all post / 0.00 posts per day]
Avatar
Last 10 Posts
Topic: I want to omit addressLine1 if Address element attribute has Standard With Attention
Posted: Monday, March 2, 2015 6:40:44 PM
If the type attribute of the Address element = “Standard With Attention” I do not want to display AddressLine1. Instead I want to only display AddressLine2, AddressLine3 and AddressLine4.
My output:
Attn: Michael, 134 W Broadway ST NW, APT 3B, Washington, DC, 12345

Expected output:
134 W Broadway ST NW, APT 3B, Washington, DC, 12345

xml code
Code:
<ProtectedAddresses>
   <Address InternalAddressID="1618613567" Type="Standard With Attention">
      <AddressLine1>Attn: Michael</AddressLine1>
      <AddressLine2>134 W Broadway ST NW</AddressLine2>
      <AddressLine3>APT 3B</AddressLine3>
      <AddressLine4>Washington, DC, 12345</AddressLine4>
   <Attention>James</Attention>
</Address>
</ProtectedAddresses>


xslt code
Code:
<xsl:for-each select="Addresses/Address">
   <xsl:for-each select="ancestor::ProtectionOrder/ProtectionOrderParties/ProtectionOrderParty/DCProtectionOrderPartyAdditional/ProtectedAddresses/Address[@InternalAddressID=current()/@InternalAddressID]">
     <xsl:for-each select="AddressLine1 | AddressLine2 | AddressLine3 | AddressLine4">
       <xsl:value-of select="."/>
       <xsl:if test="position()!=last()">, </xsl:if>
     </xsl:for-each>
     <xsl:text>; </xsl:text>
   </xsl:for-each>
</xsl:for-each>
Topic: I do I remove trailing comma after Sydney Australia 123456A,
Posted: Friday, February 27, 2015 7:24:34 PM
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.
Output
472 Case Ave, Apt 2, Saint Paul, MN, 55106; 123 Beautiful Ocean, Sydney Australia 123456A,
xml
Code:
<ProtectedAddresses>
   <Address InternalAddressID="1618212013" Type="Non Standard">
      <Location Word="HOME">Home</Location>
      <AddressLine1>472 Case Ave</AddressLine1>
      <AddressLine2>Apt 2</AddressLine2>
      <AddressLine4>Saint Paul, MN, 55106</AddressLine4>
      <City>Saint Paul</City>
      <State>MN</State>
      <Zip>55106</Zip>
   </Address>
   <Address InternalAddressID="1618212014" Type="Foreign">
      <Location Word="OTHER">Other</Location>
      <AddressLine1>123 Beautiful Ocean</AddressLine1>
      <AddressLine2>Sydney Australia 123456A</AddressLine2>
      <Foreign>true</Foreign>
   </Address>
</ProtectedAddresses>


xslt code
Code:
    
<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>

Use of the Altova User Forum(s) is governed by the Altova Terms of Use.