Content Types
Now that we have our raw XML output from the Amazon ECS web service, the next step is to transform the XML into a format or content type we can use in our client application. Amazon currently support two basic formats: xml and text. Though, this is not an accurate assessment of the supported content types as there are multiple content types for each format. What this means is that a browser will interpret different types of text-based data differently depending on the content type. The text format, for instance, contains the plain text/plain, text/html and text/javascript content types.
To better illustrate, let’s look at our search form again – this time with a content-type option between HTML and JavaScript.
As you hopefully observed, the browser treats the same data differently depending on the content type.
Since we will be manipulating the results in JavaScript, we will be using the text/javascript content type in our request parameter.
request += '&ContentType=text/javascript';
The XSLT Stylesheet
The above form triggers the JavaScript Search function posted in the previous section. The search function builds the form output into a REST request that is then submitted to the Amazon ECS Web Service server. As mentioned in the REST Syntax section, in order to turn the response into HTML, we need the Amazon Web Service to transform the XML output into JSON format using our XSL stylesheet. Since I will not be going into how to create a stylesheet, we will use the stylesheet I created for this tutorial which you can view or download here.