Chris's Rants

Thursday, January 19, 2006

Complexity

Mark Baker:
Wow, that's pretty complex coding for such a simple task, no? I'd opt for java.net (bugs, quirks, and all), or other Java client HTTP APIs (the two HTTPClient projects come to mind).
Who needs Java? A little XSLT will do the trick nicely.

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns="http://www.w3.org/TR/xhtml1/strict" xmlns:yn="urn:yahoo:yn">
<xsl:output
method="xml"
encoding="utf-8"
indent="yes"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"
media-type="text/html"
omit-xml-declaration='yes'
/>
<xsl:template match="/">
<html>
<head>
<title>Search Results</title>
</head>
<body>
<h2>Search results</h2>
<xsl:apply-templates select="document('http://api.search.yahoo.com:80/NewsSearchService/V1/newsSearch?appid=jaxws_restful_sample&type=all&results=10&sort=date&language=en&query=java')/*"/>
</body>
</html>
</xsl:template>
<xsl:template match="yn:Result">
<a href="{yn:ClickUrl}"><xsl:value-of select="yn:Title"/></a><br/>
</xsl:template>
</xsl:stylesheet>

1 Comments:

Post a Comment

<< Home