Title: Using XSLT with Web Services
1Using XSLT with Web Services
- Roger L. Costello
- XML Technologies
2Document() function is for more than just static
XML documents!
- The format of the document function is
document(url). The URL does not have to be to a
static XML document. It can be to any URL which
serves up XML. - In other words, the URL could be to a Web service
which dynamically generates XML documents!
3XSLT as a Data Aggregator
Web Service 1
Web Service 2
document(url2)
document(url1)
XSLT
4Meerkat Web Service
- Meerkat is an open service1 which aggregates
data from hundreds of sites - Here's an example of how to retrieve an XML
document of all articles that were written on
REST in the last 14 days - http//meerkat.oreillynet.com/?_flxmlsRESTt14
DAY - Here are highlights of the Meerkat API2
- _fl is used to indicate the desired "flavor" of
the result. Legal values xml, RSS 1.0, RSS 0.9,
Minimal, Tokeerkat, Meerkat - s is used to specify what you want Meerkat to
search for. Separate keywords with a plus, e.g.,
RESTSOAP means you want all articles with REST
or SOAP in them - t is used to specify how far back you want
Meerkat to look for stories. You give it a
number and then either MINUTE, HOUR, DAY, ALL.
ALL means that you want all stories (no number
needed with ALL)
1 An open service is a web service that is free
and has a publicly available API 2 See this URL
for the complete Meerkat API
http//www.oreillynet.com/lpt/a//rss/2000/05/09/me
erkat_api.html
5lt?xml version"1.0"?gt ltxslstylesheet
xmlnsxsl"http//www.w3.org/1999/XSL/Transform"
version"1.0"gt ltxsloutput
method"html"/gt ltxsltemplate match"/"gt
ltHTMLgt ltBODYgt ltxslvariable
name"Meerkat" select"document('http//www.oreill
ynet.com/meerkat/?_flxmlampsREST')"/gt
ltTABLE border"1" width"75"gt
ltTRgt ltTHgtTitlelt/THgt
ltTHgtDescriptionlt/THgt
lt/TRgt ltxslfor-each
select"Meerkat/meerkat/story"gt
ltTRgt ltTDgtltxslvalue-of
select"title"/gtlt/TDgt
ltTDgtltxslvalue-of select"description"/gtlt/TDgt
lt/TRgt
lt/xslfor-eachgt lt/TABLEgt
lt/BODYgt lt/HTMLgt lt/xsltemplategt lt/xsls
tylesheetgt
See document-example01 Note if you are running
the stylesheet behind a firewall you will need to
set the HTTP_PROXY appropriately.