Blog

Tutorial: Amazon.com Search API

Posted on
Transforming Amazon Associates Web Service Responses into HTML Using XSLT

The role of XSLT in response transformation into JSON was covered before, however, perhaps you want to use a different set of tags in Amazon Associates Web Service responses than those that are returned by default. For example, because you want to display responses on a web page, you want to turn the responses into HTML. You have two choices: you can receive the default Amazon Associates Web Service response and then transform it into HTML (or another set of XML tags) or you can tell Amazon Associates Web Service to do the transformation for you so that the result is ready for you to use. To make Amazon Associates Web Service do the work for you, you just need to reference an XSL stylesheet in your Amazon Associates Web Service request. Amazon Associates Web Service provides an XSLT (Extensible Stylesheet Language Transformation) service to ensure that even novice developers can produce rich content without complex parsing or programming. XSL is an XML-based language for transforming XML tags into HTML or any other set of XML tags. To use the Amazon Associates Web Service XSLT service, the request must be in REST, and the XSL style sheet must be referenced using the Style input parameter. To transform the response

  • Include the Style parameter in your request.
  • The referenced stylesheet must be publicly accessible.

For example, the following ItemSearch request specifies the XSLT stylesheet http://ecs.amazonaws.com/xsl/aws4/item-search.xsl.

http://ecs.amazonaws.com/onca/xml?
Service=AWSECommerceService&
AWSAccessKeyId=[AWS Access Key ID]&
Operation=ItemLookup&
IdType=ASIN&
ItemId=B00008OE6I&
ResponseGroup=Large&
Style=http://ecs.amazonaws.com/xsl/aws4/item-search.xsl