XSLスタイルシートの作成方法の詳細についてはここでは触れません。スタイルシートの例については、 http://ecs.amazonaws.com/xsl/aws4/item-search.xsl をご参照ください。
スタイルシートの先頭では、 "xmlns" を使用してネームスペースプレフィックスを定義します。ネームスペースプレフィックスには任意の名前を付けられますが、ネームスペースURLは、Product Advertising API のレスポンスで返されるネームスペースURLに一致させる必要があります。上の例では、次のように、ネームスペースプレフィックスとして "aws" を使用しています。
xmlns:aws="http://xml.amazon.com/AWSECommerceService/2006-09-13">
ネームスペースプレフィックスを作成したら、それを使用して Product Advertising API のレスポンスの要素と一致させます。例えば、"ItemLookup
Response" という名前の要素と一致させる場合、プレフィックスが "aws" であれば、一致する文字列は "aws:ItemLookup
Response" となります。
次の例は、ネームスペースプレフィックスを使用する方法と場所を示しています。
<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>