Amazon recently introduced Web Services. Having enrolled for my developer's token and downloaded the Web Services Development Kit, I elected to go for as a simplified an approach as was possible while fulfilling my aims. I chose the XSLT path. My comments throughout these pages relate entirely to Amazon's Web Services and my platform is a PC, Win98 SE, IE6 and using as tools, Microsoft's XML/XSL Viewer Tools [217 kB] and the Microsoft XML Parser SDK [1.49 mB]. This is not to suggest there is anything wrong with the many other avenues available to you - PHP, ASP, Perl, SOAP and so on. I really wanted to get a handle on XML and for me at present, XSL Transform seemed the way to go. Please read on...


electronics tutorials for ham radio




Please visit VK2TIP's Book Shelf. My personal recommendations, thanks.

LAST MODIFIED:
Sunday, 23-Jun-2013 12:55:38 PDT

THIS SHOULD BE A "PRINTER FRIENDLY PAGE" - CHECK PRINT PREVIEW.

GETTING STARTED WITH XML WEB SERVICES USING XSLT

WHY USE "XML WEB SERVICES WITH XSLT"?

UNFORTUNATELY AMAZON NO LONGER SUPPORT THIS TECHNOLOGY. THESE PAGES REMAIN FOR ARCHIVAL REASONS.

Amazon recently introduced Web Services. Having enrolled for my developer's token and downloaded the Web Services Development Kit, I elected to go for as a simplified an approach as was possible while fulfilling my aims. I chose the XSLT path. [This was all before 19th August, 2002]

NOTE: Amazon have now released v2.0 as at 1st October, 2002 - we'll wait and see what bugs might emerge first...


FURTHER UPDATE - as at 12th March, 2003

Amazon have now introduced Web Services Development Kit v2.1 which includes a number of new features such as support for the UK. When I've looked through and familiarised myself I'll include them here.

From section 5.1 Using Global Data

The XML and SOAP calls described in this document speak to US-based Amazon services. However, Amazon.com also operates Web sites in other countries, and those Web sites can also be accessed using AWS.

Amazon Web Services uses the US Web site as the default site for shopping and fulfillment. To target a request for a specific country, you need only to append a parameter to the call to identify the country in question.

Prices returned via AWS are prefixed with the appropriate currency symbol for that country.

5.2 Making Calls to Amazon.co.uk

Amazon.co.uk is the first international Web site we’re opening to Web Services. Other country-specific Web sites will be made available over the course of 2003. These include sites in Canada, Germany, France, and Japan.........

[ICP says:] Consult the SDK for further information and improvements.

[UPDATE] I've done a tutorial page on my experiences in converting my sheets to work in the U.K. Hope it helps you.


My comments throughout these pages relate entirely to Amazon's Web Services V1.0 and my platform is a PC, Win98 SE, IE6 and using as tools, Microsoft's XML/XSL Viewer Tools [217 kB] and the Microsoft XML Parser SDK [1.49 mB] - see later.

This is not to suggest there is anything wrong with the many other avenues available to you - PHP, ASP, Perl, SOAP and so on. I really wanted to get a handle on XML and for me at present, XSL Transform [XSLT] seemed to me infinitely the simplest way to go.

[24th November, 2002] I've set up a FAQ page because I find I keep replying to the same or similar questions. Even questions asked elsewhere. Also some updates appear at the end of this page.

WHAT USE IS "XML WEB SERVICES WITH XSLT"?

On this Electronics Tutorials site I recommend certain book titles relating to various aspects of learning electronics, after all this *is* an electronics tutorials site. That's my real gig.

I was particularly interested in tying in the XML feed from Amazon for each particlar book title and presenting to my site visitors as much information as was possible about my recommendation together with a simplified add-to-cart function. XSLT served my purposes admirably I must say.

WAYS TO USE "XML WEB SERVICES WITH XSLT"?

As I said Web Services allows me to present data from Amazon's XML feed to my site visitors in many, many ways. While I chose a simplified approach, don't blind yourself to the many possibilities and opportunities Web Services will present to you. For the most part, the only real challenge or limitation will be your imagination.

Now here is a typical XML feed return for one particular book title I recommend. If your browser supports XML it will show up something like this truncated version.

snapshot of xml returned from web services

Figure 1 - snapshot of XML returned from Web Services

That short screen snapshot shows you the first part of what raw data is currently available relating to this book.

With XSLT I can transform that data to present it to you so it looks like this in a link. That was my goal.

Another example depicts a price discount automatically calculated and highlighted.

HOW DO I GO ABOUT USING "XML WEB SERVICES WITH XSLT"?

1.  You need to apply for and receive a developers token from Amazon.

2.  Download the Amazon Web Services Developer Kit.

3.  I'd also recommend downloading and installing:

  A.  XML/XSL Viewer

    and a very good reference:

  B.  XML Parser SDK - MSXML SDK 3.0 Release

4.  I use and thoroughly recommend an excellent html text editor which allows you [among many other things] to change HTML tags to XHTML tags with absolute ease.

Don't minimise that, XSLT requires XHTML compatible code and if it's not up to snuff, guess what?

You don't get off the ground and you may not know why without all these tools. Believe me.

My personal recommendation, NoteTab, it's dirt cheap and, value for money. I've used nothing else for my entire site. Global 'search and replace' is worth the minimal cost alone.

5.  Bookmark this site:

http://www.w3schools.com/ for XML tutorials and XSL tutorials.

WHAT NEXT IN GETTING STARTED IN "XML WEB SERVICES WITH XSLT"?

Well you have your developer's token, Amazon Web Services Development Kit, all the tools I have outlined above and you're rearing to go...

Back on 14th August, 2002 Amazon gave approval to the use of my "buy-from-amazon" button gif.

Here it is free for your use even though I retain original copyright. Right click and save to your hard drive.

buy-from-amazon button

Figure 2 - "buy-from-amazon" button gif.

Do not contine to use this link -

http://www.electronics-tutorials.com/amazon-big/buy-from-amazon.gif

Create your own link. Please show a little courtesy in return for my efforts. Besides, I may change "Buy from Amazon" to "Stolen from...". Then you would look very silly.

6. Next download and save this file:

XSL file - http://www.electronics-tutorials.com/web-services/asin-data-to-html.xsl

ADDED: You MUST retain my copyright notices AND the link back to this page if you wish to use this XSLT sheet. That's fair...

NOTE:I have subsequently modified this file [5th October, 2002] so that "customer reviews" are now presented with biggest number of stars appearing first instead of the default which gave undue emphasis to poorer reviews. The default is lowest rating first, highest rating last.

7. Firstly, replace Electronics Tutorials with your own site name, oh duh!

8. With this file you also need to look for this toward the end of the file:

<form method="POST" action="{concat('http://www.amazon.com/o/dt/assoc/handle-buy-box=',$Asin)}">
<input type="hidden" name="{concat('asin.', $Asin)}" value="1"/>
<input type="hidden" name="tag_value" value="ianpurdie11-20"/>
<input type="hidden" name="tag-value" value="ianpurdie11-20"/>
<input type="hidden" name="dev-tag-value" value="D2U5FEMVH12ISD"/>
<input type="image" value="Add to Shopping Cart" name="submit.add-to-cart" src="http://www.electronics-tutorials.com/amazon-big/buy-from-amazon.gif" align="center" alt="Buy from Amazon" border="0" width="170" height="20"/>
</form>

9. Now change:

  A.  Change my developer's token D2U5FEMVH12ISD to your own.

  B.  Change my affiliate ID ianpurdie11-20 to your own in two places, that's right, in two places.

  C.  Finally change the location http://www.electronics-tutorials.com/amazon-big/buy-from-amazon.gif to reflect your own site.

*DO NOT* "Hotlink" to my site! Medical experts claim sudden and unexpected cyber death-rays can prove extremely painful.... I'm a happy chappy but, abuse my hospitality...

10. Now:

  A.  FTP your amended asin-data-to-html.xsl file to your site.

  B.  FTP your copy saved from above buy-from-amazon.gif file to your site.

HOW DO I LINK USING "XML WEB SERVICES WITH XSLT"?

Here is the link I used above to send you to "You clicked on..."

http://xml-na.amznxslt.com/onca/xml3?&dev-t=D2U5FEMVH12ISD&t=ianpurdie01-20&AsinSearch=0471850683&type=heavy&f=http://www.electronics-tutorials.com/amazon-big/asin-data-to-html.xsl

11. Here you need to:

  A.  Change my developer's token D2U5FEMVH12ISD to your own.

  B.  Change my affiliate ID ianpurdie01-20 to your own in one place.

  C.  Change my AsinSearch number 0471850683 to the Amazon asin number you wish to use. Place this new link anywhere on your site where you would ordinarily use a straight "asin" type link.

  D.  Finally change the location http://www.electronics-tutorials.com/amazon-big/asin-data-to-html.xsl to reflect your own site. Don't "Hotlink" back to my site! If I subsequently change it then it could prove disasterous for you. It's also very discourteous...

RANT TIME - My server logs indicate that people ARE "Hotlinking" back to my site! That's rude, keep it up and I'll name you and your site right here... I've already publicly "outed" one site on the discussion lists because I couldn't find a contact address, want to become embarrassed? Moving on...

That's it... simple...

FURTHER READING ON XSLT TO HTML

Here's a nice tutorial written by David Jacobs. David gives us a few illustrations of the power of XSLT with his tutorial Rescuing XSLT from Niche Status.

HERE'S SOME EXAMPLE LINKS TO TRY OUT

These are all links using the above method:

Essential XML Quick Reference: A Programmer's Reference to XML, XPath, XSLT, XML Schema, SOAP, and More by Aaron Skonnard, Martin Gudgin

XSLT by Doug Tidwell

XSLT Programmer's Reference 2nd Edition by Michael H. Kay

XSLT and XPath On The Edge, Unlimited Edition by Jeni Tennison

NEW ADDITIONS TO THE XSLT PAGES

As at 19th October, 2002 I made some significant modifications:

I've added a new "Customers who shopped for "[Asin]" also shopped for these similar books". Section before and after "book reviews". This has awesome potential.

I've added in facilities to buy the book or product at other Amazon international sites.

AMENDMENTS NOVEMBER, 2002

I've modified the XSLT sheet http://www.electronics-tutorials.com/amazon-big/asin-data-to-html.xsl to now include:

AMENDMENTS MARCH, 2004

I've modified the XSLT sheet http://www.electronics-tutorials.com/amazon-big/asin-search.xsl "these similar books" to now include the ability for multiple items to be added to the cart. Have a look at this example.

This is the way I did "Add to cart forms with tables" - simplified version

UPDATE TO XSL PAGES

The default xsl pages supplied by Amazon in the SDK contain an unfortunate method of producing customer review. As it presently exists [11th October, 2002] using the default pages will produce the poorest customer review first [ugh!] and the best last. Sure to get your customer excited.

I amended my code as follows:

OLD CODE:

<xsl:apply-templates select="Reviews/AvgCustomerRating"/>
<xsl:apply-templates select="Reviews/CustomerReview">
<xsl:sort select="Rating"/>
</xsl:apply-templates>

REPLACE WITH:

<xsl:apply-templates select="Reviews/AvgCustomerRating"/>
<xsl:apply-templates select="Reviews/CustomerReview">
<xsl:sort select="Reviews/CustomerReview/Rating" data-type="number" order="descending"/>
</xsl:apply-templates>

The only real change is the third line. This produces best review first, poorest last - subject to XML feed glitches.

WHAT ELSE CAN I DO USING "XML WEB SERVICES WITH XSLT"?

How long is a piece of string?

What are the limits of your imagination?

I haven't even scraped the surface yet and there are all the other means available to use Web Services. XML with XSLT is simply one of many approaches.

TRIPLE ROTATING BANNER ADS USING SSI

UPDATE

I decided that instead of using a simple rotating banner I would use a triple version of it and serve it up using Server Side Include [SSI].

Look at this - http://www.electronics-tutorials.com/web-services/banners-test.htm

What we have here are three distinct perl scripts, each with six gif files and accompanying web services links which rotate at random. This is called from within my pages using SSI.

<!--#exec cgi="/cgi-bin/banner-bank[1].cgi"-->

I also have a vertical version to run down the left hand [or right] side of a page. Really, the only limits to XML Web Services with XSLT are your imagination!

If there is sufficient interest, I'll do up a "do-it-yourself" page on this topic as well.

O.K., some interest has been displayed in other ideas.

Next [with some homework on your part] you will see how I am able to provide my version of links to five successive pages of Amazon's best Sellers searched by Keywords "Electronics-Circuits-General". Pretty cool, pretty easy too...

Here's what one link looks like, study it carefully:

<a href="http://xml-na.amznxslt.com/onca/xml3?&dev-t=D2U5FEMVH12ISD&t=ianpurdie110-20&KeywordSearch=electronics-circuits-general&mode=books&type=heavy&page=1&f=http://www.electronics-tutorials.com/amazon-big/asin-search.xsl" target="_blank">

Notice this bit, &type=heavy&page=1&f? Well it performs two different functions. Change the word "heavy" to "lite" and you don't get customer reviews. Change "&page=1" to "&page=2" or "&page=3" you will get successive pages of top ten best sellers using keywords "electronics-circuits-general".

Want more? How about adding after "http://www.electronics-tutorials.com/amazon-big/asin-search.xsl" in the link, this extra code "&sort=+pricerank". The link now becomes:

"http://www.electronics-tutorials.com/amazon-big/asin-search.xsl&sort=+pricerank"

The bestsellers would now be returned on the basis of lowest price book first then in ascending order. If you wanted the highest price book first then the extra code is "&sort=-pricerank". Notice the subtle difference.

Thanks to Alan Taylor of http://www.kokogiak.com/amazon for that tip.

Is it limited to books? I don't think so... Do a bit of research on your own. Check these examples out.

AMAZON'S TOP TEN SELLERS

Here are Amazon's top ten sellers for "Electronics-Circuits-General", from my book shelf page No. 1, well worth your time to take a look.

And here are Amazon's next top ten sellers for "Electronics-Circuits-General", from my book shelf page No. 2, also well worth your time to take a further look.

And if you are real keen, here are Amazon's Page No. 3, Amazon's Page No. 4, and Amazon's Page No. 5. Certain to be something you like in there.

BUILDING MODULAR STYLESHEET COMPONENTS

If you are learning XSL (eXtensible Stylesheet Language), you'll want to understand how to build modular and reusable components as you would in any other language. The XSL include and import elements provide an excellent capability in this regard.....

From http://www.developer.com/xml/ - Building Modular Stylesheet Components - tricks of the trade in XML and XSLT for use in Web Services.

OTHER XSLT EXAMPLES

Here's my mate COD and his all purpose "swiss army knife" approach to using Amazon Web Services with XSLT. Includes use of CSS and Javascript in places.

PERL EXAMPLES

Our friend MrRat [the name's a long story to do with motor bikes] has a good Perl script. MrRat's Amazon Products Feed. MrRat also has an excellent phpBB support forum.

PHP EXAMPLES

GPL PHP scripts.

http://www.chipdir.nl/amazon/

FAQ

[24th November, 2002] I've set up a FAQ page because I find I keep replying to the same or similar questions. Even questions asked elsewhere.

LINK TO THIS PAGE

How to link directly to this page

Want to create a page link to me from your site? It couldn't be easier. All you need to do is copy and paste, the following code. All links are greatly appreciated; I sincerely thank you for your support.

Copy and paste the following code for a text link:

<a href="http://www.electronics-tutorials.com/web-services/web-services-with-xslt.htm" target="_top">Visit Ian Purdie's "XML Web Services using XSLT" Page</a>

and it should appear like this:
Visit Ian Purdie's "XML Web Services using XSLT" Page

 

Looking for more? Like to visit my site map page:

This site is hosted at WebWizards.Net for better value [affiliated].

Copyright Ian C. Purdie © 2000 - 2004, all rights reserved. URL - http://www.electronics-tutorials.com/web-services/web-services-with-xslt.htm

All material at this site may be used by private individuals for their own non-commercial purposes. Single copies of my pages or files may be distributed to other private individuals at no charge, unless other requirements are noted on the relevant page. However, all material remains the intellectual property of Ian C. Purdie, individual contributors, or other sources who gave permission for use of their material at this site. All copyrights and trade marks are reserved by myself or the respective owners. Material may not be republished without prior written permission, nor may it be mirrored on another server without my prior written permission. Other than as provided in these pages or permissions given, translation into another language other than english and hosting pages in another country is stricly prohibited.
Commercial use prohibited without the prior written permission of www.electronics-tutorials.com

Created 19th August, 2002

Updated 6th March, 2004

Contact VK2TIP