Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 152567
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T09:38:48+00:00 2026-05-11T09:38:48+00:00

I’m trying to use the Macromedia XSLTransform class to convert XML returned from Amazon

  • 0

I’m trying to use the Macromedia XSLTransform class to convert XML returned from Amazon Web Services to HTML. Here’s the PHP page that calls the transform:

<?php require_once('includes/MM_XSLTransform/MM_XSLTransform.class.php');   $restquery = 'http://ecs.amazonaws.com/onca/xml?Service=AWSECommerceService&AWSAccessKeyId=[myid]&Operation=ItemLookup&ResponseGroup=Large&ItemId=' . htmlspecialchars($_GET['asin']); $mm_xsl = new MM_XSLTransform(); $mm_xsl->setXML($restquery); $mm_xsl->setXSL('aws1.xsl'); echo $mm_xsl->Transform(); ?> 

And here’s a snippet of the aws1.xsl page

<?xml version='1.0'?> <xsl:stylesheet    version='1.0'    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'    xmlns:aws='http://webservices.amazon.com/AWSECommerceService/2006-06-07'>    <xsl:output method='html' encoding='UTF-8' omit-xml-declaration='yes'/>    <xsl:template match='aws:Item'>     <html>       <body>         <table>           <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' disable-output-escaping='yes' />                         </xsl:attribute>                         <xsl:attribute name='border'>0</xsl:attribute>                       </img>                     </td>                   </xsl:if>                   <!-- bunch of other stuff -->                 </tr>               </table>             </td>           </tr>         </table>       </body>     </html>   </xsl:template>  </xsl:stylesheet> 

The basic code is working – I get data on the expected ASIN item back. And I know the XSL basically works because if I intentionally put an invalid attribute in I get a parser error. But what I get back is a big unformatted bunch of text instead of HTML. I’ve tried various <xsl:output method> options, but none seems to work. I thinks it’s some kind of encoding or charset problem.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T09:38:48+00:00Added an answer on May 11, 2026 at 9:38 am

    You need to create a rule to match ‘/’ or XSL will implicitly generate one for you based on a to-text conversion of the document tree.

    I would rewrite the XSL to this:

    <xsl:stylesheet    version='1.0'    xmlns:xsl='http://www.w3.org/1999/XSL/Transform'    xmlns:aws='http://webservices.amazon.com/AWSECommerceService/2006-06-07'>    <xsl:output method='html' encoding='UTF-8' omit-xml-declaration='yes'/>    <xsl:template match='/'>     <html>       <head>...</head>       <body>         <table>           <thead>...</thead>           <tbody>             <xsl:apply-templates select='//aws:Item'/>           </tbody>         </table>       </body>     </html>   </xsl:template>    <xsl:template match='aws:Item'>     <tr>       <td>...</td>     </tr>   </xsl:template>  </xsl:stylesheet> 

    OR add this template to your existing xsl

    <xsl:template match='*|@*'> <xsl:apply-templates select='*|@*'/> </xsl:template> 

    Both templates would match document root (‘/’) which is the ONLY implicit match that XSL does. This first would make ‘/’ map to the html tag which would create a table in which each table row maps to aws:item. The second would match all nodes (and attributes), output nothing, and then attempt to match all children. The first is better if you only want to process aws:Item, the second is better if you want to process all nodes. The second may (depending on the optimization features of you xslt processor and your particular xslt document) take much longer to process.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to loop through a bunch of documents I have to put
I have a bunch of posts stored in text files formatted in yaml/textile (from
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm making a simple page using Google Maps API 3. My first. One marker
I have some data like this: 1 2 3 4 5 9 2 6

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.