Portal Engine Questions on portal engine and web parts.
Version 5.x > Portal Engine > XmlDataSource View modes: 
User avatar
Member
Member
snk1324 - 4/29/2011 3:49:16 PM
   
XmlDataSource
Working with the XmlDataSource and a repeater right now. What I want to accomplish is having the XmlDataSource pull an RSS feed and use the Repeater to show it, but I can't seem to get it to work, and have not found much help in the documentation on this. I did setup a simple visual studio app to test the DataSet.ReadXml() and found that when it attempts to pull a feed it gets an error about column already belonging to the DataTable. I found this article that describes the DataSet.ReadXml() bug

http://www.kjctech.net/2009/07/31/a-column-named-ldquocommentsrdquo-already-belongs-to-this-datatable/

Any chance this could get fixed, or has anyone got a work-around, or other DataSource webpart that will work? If not, I guess I'll have to write my own, but would rather not re-invent the wheel.

Thanks!

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 5/2/2011 4:08:13 AM
   
RE:XmlDataSource
Hi,

You can show data from external RSS Feed using XML Data Source and Basic repeater webpart.

In XML Data Source, you need to specify following values:

XML URL (e.g. http://devnet.kentico.com/CMSPages/BugtrackerRss.aspx)
Table name: item

In Basic repeater, you need to fill:

Data source name: ID of XML Data Source
Transformation name: transformation with proper content, e.g. in this example:

<%# Eval("title") %>
<br />

I hope the example helps.

Best regards,
Ivana Tomanickova

User avatar
Member
Member
snk1324 - 5/2/2011 7:11:20 AM
   
RE:XmlDataSource
That works for several feeds I tried, but not for wordpress blog feeds. For example, try this feed:

http://freshlypressed.wordpress.com/feed/

Because DataSet.ReadXml() (this is what the XML Data Source uses) has problems with namespaces. In wordpress feeds, you'll see <comments> tags and <slash:comments> tags, and because of this, DataSet.ReadXml() complains

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/2/2011 9:11:39 AM
   
RE:XmlDataSource
Hello,

Thanks for additional info about possible solutions.

We have addressed this issue with colons in xml tags within the hotfix 5.5R2.11 - for 5.5 R2 version.

After applying the Hotfix, there will appear new XMLDataSource web party property "XML custom XSD schema URL". In case of most feeds it doesn't have to be set. In case of extended schema, it has to be specified so the additional elements are properly handled.

We recommend to set this new property to any existing XSD schema over the web, for example:
http://www.thearchitect.co.uk/schemas/rss-2_0.xsd
It should work then...

Hope this will help.

Regards,
Zdenek

User avatar
Member
Member
snk1324 - 5/17/2011 12:22:48 PM
   
RE:XmlDataSource
Facebook feeds present a problem as well.

http://www.facebook.com/feeds/page.php?id=56227565058&format=rss20

This results in a

"Expected DTD markup was not found."

I believe that Facebook is sniffing user agents, so it simply needs to supply that. Maybe a nice hotfix for this? Got a work-around?

User avatar
Member
Member
snk1324 - 5/17/2011 12:49:03 PM
   
RE:XmlDataSource
I was partially successful by using Feedburner to create a feed, but this results in a duplicate "link" error message. Got a magic XSD to fix this? Here's the Feedburner feed

http://feeds.feedburner.com/BDGSFaccebookWall

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/31/2011 4:57:35 PM
   
RE:XmlDataSource
Hi,

Well, that's still the same situation, there are currently some restrictions for XML datasource web part because of the nature of DataSet datatype it uses...especially multiple elements with same base name.
We will look into this more for 6.0 version, anyway in the meantime, you could also try some of the contributions from our Marketplace

Regards,
Zdenek

User avatar
Member
Member
snk1324 - 5/2/2011 7:35:39 AM
   
RE:XmlDataSource
A quick fix that could be implemented in Kentico can be found here:

http://idunno.org/archive/2005/06/24/207.aspx

It would be great to have a hotfix for this bug.

User avatar
Member
Member
snk1324 - 5/2/2011 9:00:16 AM
   
RE:XmlDataSource
I did some playing around, and the fix for this in the Kentico source is straightforward.

We simply have to change (in the XMLDataSource.cs):
DataSet dataset = new DataSet();
dataset.ReadXml(this.XmlUrl);

to:
            XmlTextReader rssReader = new XmlTextReader(this.XmlUrl);
XslCompiledTransform rssTransform = new XslCompiledTransform();
string xslt = @"<?xml version=""1.0"" encoding=""UTF-8"" ?>
<xsl:transform version=""1.0"" xmlns:xsl=""http://www.w3.org/1999/XSL/Transform"">
<xsl:output method=""xml"" omit-xml-declaration=""no""/>
<xsl:template match=""/"">
<xsl:for-each select=""rss"">
<rss version=""2.0"">
<xsl:for-each select=""channel"">
<channel>
<title><![CDATA[<xsl:value-of select=""title""/>]]></title>
<link><xsl:value-of select=""link""/></link>
<description><![CDATA[<xsl:value-of select=""description""/>]]></description>
<xsl:for-each select=""item"">
<item>
<title><![CDATA[<xsl:value-of select=""title""/>]]></title>
<link><xsl:value-of select=""link""/></link>
<description><![CDATA[<xsl:value-of select=""description""/>]]></description>
<guid><xsl:value-of select=""guid""/></guid>
</item>
</xsl:for-each>
</channel>
</xsl:for-each>
</rss>
</xsl:for-each>
</xsl:template>
</xsl:transform>
";
rssTransform.Load(new XmlTextReader(new StringReader(xslt)));

StringWriter rssStringWriter = new StringWriter();
XmlTextWriter rssWriter = new XmlTextWriter(rssStringWriter);
XPathDocument rssXPath = new System.Xml.XPath.XPathDocument(rssReader);
rssTransform.Transform(rssXPath, rssWriter);
rssReader.Close();
rssWriter.Close();

System.IO.StringReader dataSetReader = new System.IO.StringReader(rssStringWriter.ToString());
DataSet dataset = new DataSet();

dataset.ReadXml(dataSetReader);

It would be great if the Kentico dev's could take this, test it out and get us a nice hotifx here soon.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/2/2011 10:17:23 AM
   
RE:XmlDataSource
Hello,

If I'm understanding it right, the above suggested change includes the xsl transformation directly into the control, right? I believe we are not doing this due to licensing conditions.

Anyway, to check whether we are dealing with the same issue or not, could you please specify which version of KenticoCMS are you using?

If you don't have 5.5R2 with the hotfix .11 yet, have you tried to apply it (or the latest one) and use the new property for linking the extended schema, as I suggested in previous reply? I've added it to the first of your two previous posts.
For hotfix package for source code license, please contact us via support email address.

I have also forwarded this discussion to our dev's so they could take a look at this solution.

Thank you in advance for information.

Regards,
Zdenek

User avatar
Member
Member
brent.pauley@terradon.com - 5/2/2011 11:21:04 AM
   
RE:XmlDataSource
I downloaded the hotfix and it does indeed work. I had looked through the hotifxes the other day but had missed this one. I'm not sure why it would be a licensing issue to do the transformation in the control directly, but the hotfix does work, though it's not ideal to have to do that, IMHO.

User avatar
Member
Member
brian-sparkventure - 5/14/2011 7:49:50 PM
   
RE:XmlDataSource
Can you please elaborate on setting this up?

1. Why put 'item' in the table name for the data source?

2. I assume when you say 'transaction with a proper context' you mean create a new transformation, but where exactly can you do this? Do you have setup a new document type? If yes, what do you put in the document type? Everything that is in an RSS feed? When you do a datasource like this is the expectation that the data is stored in the DB, or does simply go over to the viewing web part?

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 5/17/2011 3:55:08 AM
   
RE:XmlDataSource
Hi,

1. "item" is used because it's common RSS XML element name:
http://www.w3schools.com/rss/rss_item.asp
The "items" are then the elements of the resulting DataSource table, so it determines where the data for a datasource webpart begin in the XML. The setting for the "table name" allows to use different name of the elements in the XML, e.g. with some custom structure.

2. You can create a transformation in related existing document type or create a new one. It depends on the situation. There are already some "meta" document types - EcommerceTransformations, CommunityTransformations,... grouping transformations for various purposes, that are used in places related to E-commerce (Community) features.
Similarly there's an existing CMS.RSSTransformations doctype, which - I believe - could serve well for your aim.

Regards,
Zdenek

User avatar
Member
Member
sugar.thomas08-gmail - 1/23/2012 2:08:50 AM
   
RE:XmlDataSource
I want to display simple listing by using xmldatasource. Below is the sample of my xml file . I am not able to view the listing by using the xmldatasouce and basic repeater.
<?xml version="1.0" encoding="utf-8" ?>
<item>
<url>http://google.com</url>
<title>Google Search Engine</title>
</item>

Please suggest.

User avatar
Kentico Support
Kentico Support
kentico_zdenekc - 2/3/2012 7:44:37 PM
   
RE:XmlDataSource
Hi,

Could you please send us some more details about your XMLDataSource and Basic repeater setup (web part properties)? Such XML should be easily read..
Do you have proper transformations assigned?
Also, which version of Kentico CMS are you using?

Thanks in advance for any further info.

Regards,
Zdenek

User avatar
Member
Member
vin4.net-gmail - 7/9/2012 9:34:04 AM
   
RE:XmlDataSource
Hi am facing problem in specifying the table name in the XML data source repeater.

I am trying read a xml file by spacing it in a folder under my project root. Added XML data source repeater on the page, specified the file path and added a basic repeater with data source control id and transformation for fetching data from the xml file.

But its not showing any data. I guess, need to specify the table name but I am not getting how to find out the table name.

Please help me to achieve this.

Thanks in advance.

User avatar
Kentico Developer
Kentico Developer
kentico_ivanat - 7/14/2012 6:24:15 PM
   
RE:XmlDataSource
This topic continue in this thread.