Collaborate06 has started with a bang ... this hotel is huge, just to give you an idea how big ... they have a river running through the grounds of the hotel (all of which are under glass) and you can ride a boat and get a half hour guided tour of the hotel. The fish are huge, wish I had brought my rod!
Monday is pretty much given over to Special Interest Groups during the day. This evening the exhibition floor opened to floods of attendees with burning questions. We have an Applications Technology pod staffed by yours truly and a few other brave souls. It was pretty busy ... not OpenWorld busy but busy enough.
Adding External Data
I got a request tonight; 'How can I bring other data into the layout that is not in the datasource provided?' ... there are a couple of ways to do this. Now Im not going to tell you how to execute a query from the template to pull in more data from the db ... that starts to tie the template to the data extract too closely and we go down a path we do not want to go ... that said its possible but we're not recommending it. If you have some static data or can call a URL to pull XML data; maybe a servlet or static XML document then you can easily integrate this into you output.
There is a function in XSL called document(), we can use this to pull XML data into the template very easily. Basically we declare the function at the top of the template. For this example lets use a well known RSS news feed.
<xsl:variable name="news" select="document('http://rss.news.yahoo.com/rss/topstories')"/>
We create a variable, 'news' and assign the RSS feed results to it using the document function. The variable will contain a nodeset or tree of data not just a single element.
<?xml version="1.0" encoding="iso-8859-1" ?>
<rss version="2.0" xmlns:media="http://search.yahoo.com/mrss">
<channel>
<title>Yahoo! News: Top Stories</title>
<copyright>Copyright (c) 2006 Yahoo! Inc. All rights reserved.</copyright>
<link>http://news.yahoo.com/i/716</link>
<description>Top Stories</description>
<language>en-us</language>
<lastBuildDate>Tue, 25 Apr 2006 06:18:26 GMT</lastBuildDate>
<ttl>5</ttl>
<image> <title>Yahoo! News</title>
...
We can now reference the "news" variable and its contents in the template.

The image shows a portion of a template using the "news" variable.
FE - <?for-each:$news/*?> - this is pulling the complete nodeset into the for-each loop
Channel Link - <?/rss/channel/title?> simply referencing the title element
Link - this is a piece of text i.e. 'Link' with an MSWord hyperlink layered over the top,{/rss/channel/link} - I'll cover the whole notion of links and dynamic links in another post.
FE - <?for-each:item?> - now we start looping over the news item data just as we would normally.
The rest you can check out yourselves, the template is posted here. When you test remember you may need to set a proxy to get out of your firewall.
So pretty simple huh? Of course you can get a lot more imaginative, say your XML source accepted parameters you could pass parameter values based on the main data set, you can build dynamic URLs to open another report, even a self service web page or an Oracle Form or anything else for that matter.
Busy day tomorrow with panels, presentations and the demogrounds ... see ya!
Comments (6)
Interesting...when I try it I get an error though: java.net.ConnectException: Connection refused: connect (in Template Builder).
Is there any specific version I need to be on?
/Daniel
Posted by Daniel | April 25, 2006 3:16 AM
Posted on April 25, 2006 03:16
Hi Daniel
Are you running behind a company firewall? If so XMLP can not probably resolve the URL. In the next release of template builder (coming soon) you can configure the proxy.
For now trying grabbing the XML and mounting on a company server to test.
Tim
Posted by Tim Dexter | April 26, 2006 6:54 PM
Posted on April 26, 2006 18:54
I was on a client site that uses a proxy. Here at the office it works great.
Posted by Daniel | April 28, 2006 7:09 AM
Posted on April 28, 2006 07:09
I am promoting my blogs from one end to the other flatter a icipatation in opposystemizationment colloquy forums and, unfortunately, most dissects or responses I am getting on these boards, not unswervingly in my blog contentions …
Posted by Robatbzv | February 17, 2009 7:41 AM
Posted on February 17, 2009 07:41
Hi Daniel
Are you running behind a company firewall? If so XMLP can not probably resolve the URL. In the next release of template builder (coming soon) you can configure the proxy.
For now trying grabbing the XML and mounting on a company server to test.
Tim
Posted by Hotels Publihser | October 5, 2009 12:43 PM
Posted on October 5, 2009 12:43
Thanks I just found your site but have some blogs I would definitely want to nominate!
Posted by modeller | November 10, 2009 6:19 AM
Posted on November 10, 2009 06:19