Creating an XSL Style Sheet
It is beyond the scope of this book to explain in detail how to create an XSL style sheet. To see a sample style sheet, go to http://ecs.amazonaws.com/xsl/aws4/item-search.xsl.
You use "xmlns" to define a namespace prefix at the top of the style sheet. You may name the namespace prefix anything, however, the namespace URL must match the namespace URL that is returned in the Product Advertising API response. The preceding example uses "aws" as the namespace prefix, as follows.
xmlns:aws="http://xml.amazon.com/AWSECommerceService/2006-09-13">
Once you have created a namespace prefix, use it to match elements in the Product Advertising API response. For example, if you are trying to match an element
called "ItemLookup
Response," and your prefix
is "aws," the matching string would be
aws:ItemLookup
Response.
The following example shows how and where the namespace prefix should be used.
<xsl:template match="/"> <xsl:apply-templates select="aws:Items/aws:Item"/> </xsl:template> <xsl:template match="aws:Items/aws:Item"> <tr> <td style="border-bottom:C0C0C0 dotted 1px;padding:10px"> <table cellpadding="0" cellspacing="0" style="width: 90%;padding:5px"> <tr> <xsl:if test="aws:SmallImage/aws:URL"> <td valign="top" width="50"> <img> <xsl:attribute name="src"> <xsl:value-of select="aws:SmallImage/aws:URL" /> </xsl:attribute> <xsl:attribute name="border">0</xsl:attribute> </img> </td> </xsl:if> <td valign="top"> <xsl:value-of select="aws:ItemAttributes/aws:Title" /> <br /> <span style="font-size:10px"> <xsl:if test="aws:ItemAttributes/aws:Author"> by <xsl:value-of select="aws:ItemAttributes/aws:Author" /> </xsl:if> <xsl:if test="aws:ItemAttributes/aws:Artist"> by <xsl:value-of select="aws:ItemAttributes/aws:Artist" /> </xsl:if> <xsl:if test="aws:ItemAttributes/aws:Director"> by <xsl:value-of select="aws:ItemAttributes/aws:Director" /> </xsl:if> <xsl:if test="aws:ItemAttributes/aws:Composer"> by <xsl:value-of select="aws:ItemAttributes/aws:Composer" /> </xsl:if> <xsl:if test="aws:ItemAttributes/aws:Manufacturer"> from <xsl:value-of select="aws:ItemAttributes/aws:Manufacturer" /> </xsl:if> </span> <br /> <br /> <span style="font-size:11px;"> List Price: <xsl:value-of select="aws:ItemAttributes/aws:ListPrice/aws:FormattedPrice" /> </span> </td> </tr> </table> </td> </tr> </xsl:template>