50 likes | 133 Views
Using XSLT with Web Services. Roger L. Costello XML Technologies. Document() 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.
E N D
Using XSLT with Web Services Roger L. Costello XML Technologies
Document() 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!
XSLT as a Data Aggregator Web Service 2 Web Service 1 document(url2) document(url1) XSLT
Meerkat Web Service • Meerkat is an open service[1] 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/?_fl=xml&s=REST&t=14DAY • Here are highlights of the Meerkat API[2] • _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., REST+SOAP 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/meerkat_api.html
<?xml version="1.0"?> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <HTML> <BODY> <xsl:variable name="Meerkat" select="document('http://www.oreillynet.com/meerkat/?_fl=xml&s=REST')"/> <TABLE border="1" width="75%"> <TR> <TH>Title</TH> <TH>Description</TH> </TR> <xsl:for-each select="$Meerkat/meerkat/story"> <TR> <TD><xsl:value-of select="title"/></TD> <TD><xsl:value-of select="description"/></TD> </TR> </xsl:for-each> </TABLE> </BODY> </HTML> </xsl:template> </xsl:stylesheet> See document-example01 [Note: if you are running the stylesheet behind a firewall you will need to set the HTTP_PROXY appropriately.]