Listing 4. The last step is a style sheet
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:an="http://ananas.org/2002/sample">
<xsl:template match="an:address-book">
<sect1><xsl:apply-templates/></sect1>
</xsl:template>
<xsl:template match="an:alias">
<address>
<xsl:variable name="id" select="an:id"/>
<xsl:for-each select="/an:address-book/an:note[an:id = $id]">
<personname><xsl:value-of select="an:fields/an:field[an:key='name']/an:value"/></personname>
<xsl:if test="an:fields/an:field[an:key='country']/an:value">
<street><xsl:value-of select="an:fields/an:field[an:key='address']/an:value"/></street>
<postcode><xsl:value-of select="an:fields/an:field[an:key='zip']/an:value"/></postcode>
<city><xsl:value-of select="an:fields/an:field[an:key='city']/an:value"/></city>
<state><xsl:value-of select="an:fields/an:field[an:key='state']/an:value"/></state>
<country><xsl:value-of select="an:fields/an:field[an:key='country']/an:value"/></country>
</xsl:if>
</xsl:for-each>
<email><xsl:value-of select="an:email"/></email>
</address>
</xsl:template>
<xsl:template match="an:note"/>
</xsl:stylesheet>
|