We definitely don't have this folder. How can I get hold of its contents?
<Data> <Datum ID="MAXITEMS" Name="Maximum Number of Items" Type="Number">3</Datum> <Datum ID="SHOWPUBDATE" Name="Include Publish Date" Type="Boolean">true</Datum> <External> <Parameters> <Datum ID="feedURL" Name="URL" Type="String">http://rss.news.yahoo.com/rss/topstories</Datum> </Parameters> <Object Scope="local">com.interwoven.livesite.external.runtime.Web</Object> <Method>urlGet</Method> </External></Data>
<Properties ComponentID="1186521799982"> <Datum ID="BODYCLASS" Name="Component CSS Class" Type="String">rss-body</Datum> <Datum ID="ITEMCLASS" Name="Item CSS Class" Type="String">rss-item</Datum> <Datum ID="TITLECLASS" Name="Title CSS Class" Type="String">rss-title</Datum> <Datum ID="DATECLASS" Name="Date and Time CSS Class" Type="String">rss-date</Datum> <Datum ID="STORYCLASS" Name="Story CSS Class" Type="String">rss-story</Datum></Properties>
<!DOCTYPE html-entities SYSTEM "http://www.interwoven.com/livesite/xsl/xsl-html.dtd"><xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <!-- Skin: Default (Default Browser Type) --> <xsl:include href="http://www.interwoven.com/livesite/xsl/HTMLTemplates.xsl"/> <xsl:include href="http://www.interwoven.com/livesite/xsl/StringTemplates.xsl"/> <xsl:template match="/"> <xsl:choose> <xsl:when test="0 = string-length(/Properties/Datum[@ID='BODYCLASS'])"> <div> <xsl:attribute name="style">font-size:75%;font-family:sans-serif</xsl:attribute> <xsl:apply-templates select="/Properties/Data/Result/Response/rss/channel" /> </div> </xsl:when> <xsltherwise> <div> <xsl:attribute name="class"><xsl:value-of select="/Properties/Datum[@ID='BODYCLASS']" /></xsl:attribute> <xsl:apply-templates select="/Properties/Data/Result/Response/rss/channel" /> </div> </xsltherwise> </xsl:choose> </xsl:template> <xsl:template match="channel"> <xsl:for-each select="item"> <xsl:sort select="pubDate" order="descending"/> <xsl:if test="position() <= /Properties/Data/Datum[@ID='MAXITEMS']"> <xsl:call-template name="stories"> <xsl:with-param name="title" select="title"/> <xsl:with-param name="link" select="link"/> <xsl:with-param name="pubDate" select="pubDate"/> <xsl:with-param name="description" select="description"/> </xsl:call-template> </xsl:if> </xsl:for-each> </xsl:template> <xsl:template name="stories"> <div> <xsl:attribute name="class"><xsl:value-of select="/Properties/Datum[@ID='ITEMCLASS']" /></xsl:attribute> <xsl:choose> <xsl:when test="0 = string-length(/Properties/Datum[@ID='TITLECLASS'])"> <div style="padding:10px 2px 0px 2px; font-size:125%; font-weight:bold;"> <a> <xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute> <xsl:value-of select="title"/> </a> </div> </xsl:when> <xsltherwise> <div> <xsl:attribute name="class"><xsl:value-of select="/Properties/Datum[@ID='TITLECLASS']" /></xsl:attribute> <a> <xsl:attribute name="href"><xsl:value-of select="link"/></xsl:attribute> <xsl:value-of select="title"/> </a> </div> </xsltherwise> </xsl:choose> <xsl:if test="/Properties/Data/Datum[@ID='SHOWPUBDATE'] = 'true'"> <div> <xsl:attribute name="class"><xsl:value-of select="/Properties/Datum[@ID='DATECLASS']" /></xsl:attribute> <xsl:value-of select="pubDate"/> </div> </xsl:if> <div> <xsl:attribute name="class"><xsl:value-of select="/Properties/Datum[@ID='STORYCLASS']" /></xsl:attribute> <xsl:value-of select="description" disable-output-escaping="yes"/> </div> </div> </xsl:template></xsl:stylesheet>
I've built a working component based on the code you've given me, but (there's always a but ... ) it doesn't seem to work for all feeds. For example, it will happily display the BBC news feed (http://newsrss.bbc.co.uk/rss/newsonline_uk_edition/front_page/rss.xml), but when I try to display this one http://www.pebbleweb.co.uk/hull/rss.aspx/blog/573, I just see the raw feed xml in the xml viewer when previewing the component. Any ideas as to why this is happening wopuld be much appreciated. I confess to not knowing too much about this area ...
"text/xml"
String urlString = ...;URL url = new URL(urlString);URLConnection connection = url.openConnection();InputStream is = new BufferedInputStream(connection.getInputStream());Document doc = Dom4jUtils.newDocument();// parse the XML stream into a DOMDocument xml = Dom4jUtils.newDocument(is);// wrap this XML tree in a top-level element called "Xml"doc.addElement("Xml").add(xml.getRootElement().detach());return doc;
Paul,I thought I posted a reply to this thread but it's not showing up. (Am I being censored? :-) Anyway, now that you mentioned it, I recall a problem with the built-in class... it's looking for an HTTP content type of "text/xml", and when it finds anything else at all, it just returns the content in a CDATA section instead of parsing into XML elements. So I'd bet that some of the services you tried return text/xml and others return application/xml or something else. A silly technicality, but I think that's your problem.What I did in the past was write my own external. I started to ask permission to post that code here, but after looking at it it has other hooks and such that make it more complicated than you need. So I'll post the basics of it here and if it's helpful I can elaborate. String urlString = ...;URL url = new URL(urlString);URLConnection connection = url.openConnection();InputStream is = new BufferedInputStream(connection.getInputStream());Document doc = Dom4jUtils.newDocument();// parse the XML stream into a DOMDocument xml = Dom4jUtils.newDocument(is);// wrap this XML tree in a top-level element called "Xml"doc.addElement("Xml").add(xml.getRootElement().detach());return doc; That relies on the Dom4jUtils class, which is in livesite.jar or one of those. Other than that, it should be straightforward... just parses the contents into XML regardless of content type. Of course, you'd have to add your own exception handling, but you get the idea. This would return a Dom4j Document, so it could be part of a method called as an External from a component.Stokes.