I want to omit addressLine1 if Address element attribute has

Here should go questions about transforming XML with XSLT and FOP.
winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

I want to omit addressLine1 if Address element attribute has

Post by winkimjr2 » Mon Mar 02, 2015 9:28 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: Select all

<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: Select all

<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>

lief.erickson
Posts: 14
Joined: Sun Mar 01, 2015 8:26 am

Re: I want to omit addressLine1 if Address element attribute

Post by lief.erickson » Mon Mar 02, 2015 10:29 pm

Since you know that you do not want AddressLine1 included in your output, in your XSLT change

Code: Select all

<xsl:for-each select="AddressLine1 | AddressLine2 | AddressLine3 | AddressLine4">
to

Code: Select all

<xsl:for-each select="AddressLine2 | AddressLine3 | AddressLine4">
-Lief

winkimjr2
Posts: 62
Joined: Thu Jun 26, 2014 9:00 pm

Re: I want to omit addressLine1 if Address element attribute

Post by winkimjr2 » Tue Mar 03, 2015 1:41 am

-Lief thanks for your response!

Post Reply