<?xml version="1.0" encoding="UTF-8"?><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:aws="http://webservices.amazon.com/AWSECommerceService/2005-10-05">  <xsl:output method="text" media-type="text/javascript" encoding="UTF-8"/>  <xsl:template match="/">    <xsl:apply-templates select="aws:ItemSearchResponse/aws:OperationRequest/aws:Arguments"/> ({  "Keywords" : "<xsl:apply-templates select="aws:ItemSearchResponse/aws:Items/aws:Request/aws:ItemSearchRequest/aws:Keywords"/>",  "TotalResults" : <xsl:value-of select="aws:ItemSearchResponse/aws:Items/aws:TotalResults"/>,  "TotalPages" : <xsl:value-of select="aws:ItemSearchResponse/aws:Items/aws:TotalPages"/>,  "Items" : [    <xsl:apply-templates select="aws:ItemSearchResponse/aws:Items/aws:Item"/>  ]});  </xsl:template>  <xsl:template match="/aws:ItemSearchResponse/aws:OperationRequest/aws:Arguments/aws:Argument[@Name='callback']">    <xsl:value-of select="@Value"/>  </xsl:template>  <xsl:template match="/aws:ItemSearchResponse/aws:Items/aws:Item">    {      "ASIN" : "<xsl:value-of select="aws:ASIN"/>",      "DetailPageURL" : "<xsl:value-of select="aws:DetailPageURL"/>",      "SalesRank" : "<xsl:value-of select="aws:SalesRank"/>",      "SmallImage" : {         "URL" : "<xsl:value-of select="aws:SmallImage/aws:URL"/>",         "Height" : "<xsl:value-of select="aws:SmallImage/aws:Height"/>",         "Width" : "<xsl:value-of select="aws:SmallImage/aws:Width"/>"      },      "MediumImage" : {         "URL" : "<xsl:value-of select="aws:MediumImage/aws:URL"/>",         "Height" : "<xsl:value-of select="aws:MediumImage/aws:Height"/>",         "Width" : "<xsl:value-of select="aws:MediumImage/aws:Width"/>"      },      "LargeImage" : {         "URL" : "<xsl:value-of select="aws:LargeImage/aws:URL"/>",         "Height" : "<xsl:value-of select="aws:LargeImage/aws:Height"/>",         "Width" : "<xsl:value-of select="aws:LargeImage/aws:Width"/>"      },      "ItemAttributes" : {         "Author" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Author"/>",         "Binding" : "<xsl:value-of select="aws:ItemAttributes/aws:Binding"/>",         "Creator" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Creator"/>",         "Label" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Label"/>",         "ListPrice" : {            "Amount" : "<xsl:value-of select="aws:ItemAttributes/aws:ListPrice/aws:Amount"/>",            "CurrencyCode" : "<xsl:value-of select="aws:ItemAttributes/aws:ListPrice/aws:CurrencyCode"/>",            "FormattedPrice" : "<xsl:value-of select="aws:ItemAttributes/aws:ListPrice/aws:FormattedPrice"/>"         },         "Manufacturer" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Manufacturer"/>",         "PackageDimensions" : {            "Length" : "<xsl:value-of select="aws:ItemAttributes/aws:PackageDimensions/aws:Length"/> <xsl:value-of select="aws:ItemAttributes/aws:PackageDimensions/aws:Length/@Units"/>",            "Width" : "<xsl:value-of select="aws:ItemAttributes/aws:PackageDimensions/aws:Width"/> <xsl:value-of select="aws:ItemAttributes/aws:PackageDimensions/aws:Width/@Units"/>"         },         "ProductGroup" : "<xsl:value-of select="aws:ItemAttributes/aws:ProductGroup"/>",          "PublicationDate" : "<xsl:value-of select="aws:ItemAttributes/aws:PublicationDate"/>",         "Publisher" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Publisher"/>",         "Studio" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Studio"/>",         "Title" : "<xsl:apply-templates select="aws:ItemAttributes/aws:Title"/>"      },      "OfferSummary" : {         "LowestNewPrice" : {             "Amount" : "<xsl:value-of select="aws:OfferSummary/aws:LowestNewPrice/aws:Amount"/>",             "CurrencyCode" : "<xsl:value-of select="aws:OfferSummary/aws:LowestNewPrice/aws:CurrencyCode"/>",             "FormattedPrice" : "<xsl:value-of select="aws:OfferSummary/aws:LowestNewPrice/aws:FormattedPrice"/>"         },         "TotalNew" : <xsl:value-of select="aws:OfferSummary/aws:TotalNew"/>,         "TotalUsed" : <xsl:value-of select="aws:OfferSummary/aws:TotalUsed"/>,         "TotalCollectible" : <xsl:value-of select="aws:OfferSummary/aws:TotalCollectible"/>,         "TotalRefurbished" : <xsl:value-of select="aws:OfferSummary/aws:TotalRefurbished"/>      },      "Offers" : {         "TotalOffers" : <xsl:value-of select="aws:Offers/aws:TotalOffers"/>,         "TotalOfferPages" : <xsl:value-of select="aws:Offers/aws:TotalOffers"/>,         "Offer" : [           <xsl:apply-templates select="aws:Offers/aws:Offer"/>          ]      },      "CustomerReviews" : {         <xsl:if test="aws:CustomerReviews/aws:AverageRating">         "AverageRating" : "<xsl:value-of select="aws:CustomerReviews/aws:AverageRating"/>",         "TotalReviews" : <xsl:value-of select="aws:CustomerReviews/aws:TotalReviews"/>,         "TotalReviewPages" : <xsl:value-of select="aws:CustomerReviews/aws:TotalReviewPages"/>,         </xsl:if>         "Review" : [            <xsl:apply-templates select="aws:CustomerReviews/aws:Review"/>          ]      },      "EditorialReviews" : [         <xsl:apply-templates select="aws:EditorialReviews/aws:EditorialReview"/>      ],      "SimilarProducts" : [         <xsl:apply-templates select="aws:SimilarProducts/aws:SimilarProduct"/>      ]    }    <xsl:if test="position()!=last()">,</xsl:if>  </xsl:template>  <xsl:template match="aws:ItemAttributes/aws:Author"><xsl:value-of select="."/><xsl:if test="position()!=last()">, </xsl:if></xsl:template>    <xsl:template match="aws:ItemAttributes/aws:Creator"><xsl:value-of select="."/>(<xsl:value-of select="@Role"/>)<xsl:if test="position()!=last()">, </xsl:if></xsl:template>  <xsl:template match="aws:Offers/aws:Offer">            {               "Merchant" : {                    "MerchantId" : "<xsl:value-of select="aws:Merchant/aws:MerchantId"/>",                    "GlancePage" : "<xsl:value-of select="aws:Merchant/aws:GlancePage"/>"               },               "OfferAttributes" : {                    "Condition" : "<xsl:value-of select="aws:OfferAttributes/aws:Condition"/>"               },               "OfferListing" : {                    "OfferListingId" : "<xsl:value-of select="aws:OfferListing/aws:OfferListingId"/>",                    "Price" : {                        "Amount" : "<xsl:value-of select="aws:OfferListing/aws:Price/aws:Amount"/>",                        "CurrencyCode" : "<xsl:value-of select="aws:OfferListing/aws:Price/aws:CurrencyCode"/>",                        "FormattedPrice" : "<xsl:value-of select="aws:OfferListing/aws:Price/aws:FormattedPrice"/>"                    },                   "Availability" : "<xsl:value-of select="aws:OfferListing/aws:Availability"/>",                   "IsEligibleForSuperSaverShipping" : <xsl:value-of select="aws:OfferListing/aws:IsEligibleForSuperSaverShipping"/>               },            }            <xsl:if test="position()!=last()">, </xsl:if>  </xsl:template>  <xsl:template match="aws:CustomerReviews/aws:Review">            {               "ASIN" : "<xsl:value-of select="aws:ASIN"/>",               "Rating" : "<xsl:value-of select="aws:Rating"/>",               "HelpfulVotes" : "<xsl:value-of select="aws:HelpfulVotes"/>",               "CustomerId" : "<xsl:value-of select="aws:CustomerId"/>",               "TotalVotes" : "<xsl:value-of select="aws:TotalVotes"/>",               "Date" : "<xsl:value-of select="aws:Date"/>",               "Summary" : "<xsl:apply-templates select="aws:Summary"/>",               "Content" : "<xsl:apply-templates select="aws:Content"/>"            }            <xsl:if test="position()!=last()">, </xsl:if>  </xsl:template>  <xsl:template match="aws:EditorialReviews/aws:EditorialReview">        {           "Source" : "<xsl:value-of select="aws:Source"/>",           "Content" : "<xsl:apply-templates select="aws:Content"/>"        }        <xsl:if test="position()!=last()">, </xsl:if>  </xsl:template>  <xsl:template match="aws:SimilarProducts/aws:SimilarProduct">        {           "ASIN" : "<xsl:value-of select="aws:ASIN"/>",           "Title" : "<xsl:apply-templates select="aws:Title"/>"        }        <xsl:if test="position()!=last()">, </xsl:if>  </xsl:template>  <xsl:template match="aws:Keywords">    <xsl:call-template name="escape">      <xsl:with-param name="str">        <xsl:value-of select="normalize-space(.)" />      </xsl:with-param>    </xsl:call-template>  </xsl:template>  <xsl:template match="aws:ItemAttributes/*">    <xsl:call-template name="escape">      <xsl:with-param name="str">        <xsl:value-of select="normalize-space(.)" />      </xsl:with-param>    </xsl:call-template>  </xsl:template>  <xsl:template match="aws:Review/*">    <xsl:call-template name="escape">      <xsl:with-param name="str">        <xsl:value-of select="normalize-space(.)" />      </xsl:with-param>    </xsl:call-template>  </xsl:template>  <xsl:template match="aws:EditorialReview/*">    <xsl:call-template name="escape">      <xsl:with-param name="str">        <xsl:value-of select="normalize-space(.)" />      </xsl:with-param>    </xsl:call-template>  </xsl:template>  <xsl:template match="aws:SimilarProduct/*">    <xsl:call-template name="escape">      <xsl:with-param name="str">        <xsl:value-of select="normalize-space(.)" />      </xsl:with-param>    </xsl:call-template>  </xsl:template>  <xsl:template name="escape">    <xsl:param name="str"/>    <xsl:call-template name="replace">      <xsl:with-param name="from">&#34;</xsl:with-param>      <xsl:with-param name="to">\&#34;</xsl:with-param>      <xsl:with-param name="str" select="normalize-space($str)" />    </xsl:call-template>  </xsl:template>  <xsl:template name="replace">    <xsl:param name="str"/>    <xsl:param name="from"/>    <xsl:param name="to"/>    <xsl:choose>      <xsl:when test="contains($str, $from)">        <xsl:value-of select="substring-before($str, $from)"/>        <xsl:value-of select="$to"/>        <xsl:call-template name="replace">          <xsl:with-param name="from" select="$from"/>          <xsl:with-param name="to" select="$to"/>          <xsl:with-param name="str" select="substring-after($str, $from)"/>        </xsl:call-template>      </xsl:when>      <xsl:otherwise>        <xsl:value-of select="$str"/>      </xsl:otherwise>    </xsl:choose>  </xsl:template>    </xsl:stylesheet>
