Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL translation with if/then statement

Status
Not open for further replies.

lassehammer

IS-IT--Management
Joined
May 10, 2004
Messages
9
Location
GB
I have an XML file containing 5 orders. 4 of the orders have a billing address that is the shipping address and no shipping address fields. The 5th order have both a billing address and a seperate Shipping address. How do I write the XSL so that the shipping address always should be used if present?
Thanks

 
Use <xsl:choose>
For example:
<xsl:template match="order">
<!-- anything about the order -->
<xsl:value-of select="lastname" />
<xsl:choose>
<xsl:when test="shipping_adress/zip!=''">
<!-- print shipping adress -->
<xsl:value-of select="shipping_adress/zip" />
</xsl:when>
<xsl:otherwise>
<!-- print regular adress -->
<xsl:value-of select="adress/zip" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top