[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: feed reader problem
here is the servlet program that has hardcoded url TransformerFactory tFactory = TransformerFactory.newInstance(); // Get the XML input document and the stylesheet. //Source xmlSource = new StreamSource(new URL("http://www.bbc.co.uk/syndication/feeds/news/ukfs_news/world/rss091.xml").openStream()); Source xmlSource1 = new StreamSource(new URL("http://www.rediff.com/rss/usrss.xml").openStream()); Source xmlSource2 = new StreamSource(new URL("http://www.rediff.com/rss/newsrss.xml").openStream()); Source xslSource = new StreamSource(new URL("http://..../xslt/getrss.xsl").openStream()); Source xslSource1 = new StreamSource(new URL("http://...xslt/getrss.xsl").openStream()); // Generate the transformer. Transformer transformer = tFactory.newTransformer(xslSource); // Perform the transformation, sending the output to the response. // transformer.transform(xmlSource, new StreamResult(out)); transformer.transform(xmlSource1, new StreamResult(out)); transformer.transform(xmlSource2, new StreamResult(out)); and code in xsl file is as follows <!-- getRSS.xsl: retrieve RSS feed(s) and convert to HTML. --> <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:dc="http://purl.org/dc/elements/1.1/" version="1.0"> <xsl:output method="html"/> <xsl:template match="/"> <html><head><title>Today's Headlines</title></head> <style><xsl:comment> p { font-size: 8pt; font-family: arial,helvetica; } h1 { font-size: 12pt; font-family: arial,helvetica; font-weight: bold; } a:link { color:blue; font-weight: bold; text-decoration: none; } a:visited { font-weight: bold; color: darkblue; text-decoration: none; } </xsl:comment></style> <body> <form method='get' action="TempClient"> <input type="text" name="code" size="5"/> <input type="submit" value="Get Temp"/> </form> <xsl:apply-templates/> </body></html> </xsl:template> <xsl:template match="channel"> <xsl:apply-templates select="document(@src)"/> </xsl:template> <!-- Named template outputs HTML a element with href link and RSS description as title to show up in mouseOver message. --> <xsl:template name="a-element"> <xsl:element name="a"> <xsl:attribute name="href"> <xsl:apply-templates select="*[local-name()='link']"/> </xsl:attribute> <xsl:attribute name="title"> <xsl:apply-templates select="*[local-name()='description']"/> </xsl:attribute> <xsl:value-of select="*[local-name()='title']"/> </xsl:element> </xsl:template> <!-- Output RSS channel name as HTML a link inside of h1 element. --> <xsl:template match="*[local-name()='channel']"> <xsl:element name="h1"> <xsl:call-template name="a-element"/> </xsl:element> <!-- Following line for RSS .091 --> <xsl:apply-templates select="*[local-name()='item']"/> </xsl:template> <!-- Output RSS item as HTML a link inside of p element. --> <xsl:template match="*[local-name()='item']"> <xsl:element name="p"> <xsl:call-template name="a-element"/> <xsl:text> </xsl:text> <xsl:if test="dc:date"> <!-- Show date if available --> <xsl:text>( </xsl:text> <xsl:value-of select="dc:date"/> <xsl:text>) </xsl:text> </xsl:if> </xsl:element> </xsl:template> </xsl:stylesheet> when i run this it pulls the two feeds applys xslt and displays to user....but i want to display information in a better way may be in tables as said before...each channel in a table... raj
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|