This is a migrated thread and some comments may be shown as answers.

RSS Feed / XML datasource - Invalid template

1 Answer 74 Views
Data Source
This is a migrated thread and some comments may be shown as answers.
Charles
Top achievements
Rank 1
Charles asked on 27 Jun 2012, 11:03 AM
Hi

I cannot find any equivalent issue/documentation/howto on my specific data structure.

I am getting an invalid template"

Please advise...

Code:

     <div id="example" class="k-content">
                <script id="template" type="text/x-kendo-template">
                <li class="Notice">
                <table style="width: 100%;">
                <tr><td>#= guid#</td><td>#= category#</td><td>#= pubDate#</td></tr>
                <tr><td>#= title#</td><td colspan="2">#= description#</td></tr>
                <tr><td>#= ip:Type#</td><td>#= ip:TimeDown#</td><td>#= ip:ETTR#</td></tr>
                <tr><td>#= ip:Progress#</td><td>#= ip:AreasAffected#</td><td>#= ip:Status#</td></tr>
            </table>
                </li>
            </script>
            <script type="text/javascript">
                $(document).ready(function () {
                    var template = kendo.template($("#template").html());
                    var dataSource = new kendo.data.DataSource({
                        transport: {
                            read: "http://www.telkomsa.net/rss/saix.xml"
                        },
                        schema: {
                            type: "xml",
                            data: "/item",
                            model: {
                                fields: {
                                    guid: "guid/text()",
                                    pubDate: "pubDate/text()",
                                    category: "category/text()",
                                    title: "title/text()",
                                    description: "description/text()",
                                    pubDate: "pubDate/text()",
                                    ip: {
                                        Type: "Type/text()",
                                        TimeDown: "TimeDown/text()",
                                        ETTR: "ETTR/text()",
                                        Progress: "Progress/text()",
                                        AreasAffected: "AreasAffected/text()",
                                        Status: "Status/text()"
                                       } //ip
                                    } //fields
                                 } // model
                             } //schema
                    }); //datasource
                }); //ready
           </script>
</div>

XML Data:

<item xmlns:ip="www.ipact.telkom-ipnet.co.za"><guid isPermaLink="false">NN0008585</guid><pubDate>Fri, 22 Jun 2012 14:31:03 +0200</pubDate><category>Planned Work</category><title>Link - To perform Planned Maintenance on the Telkom Network at Secunda</title><description>&lt;center&gt;&lt;b&gt;Ref:&lt;/b&gt; NN0008585&lt;/center&gt;&lt;b&gt;Category&lt;/b&gt; Planned Work &lt;b&gt;Type:&lt;/b&gt; Planned Work &lt;b&gt;Status:&lt;/b&gt; New&lt;BR&gt;&lt;b&gt;TimeDown:&lt;/b&gt; Thu, 28 Jun 2012 20:00:00 +0200 &lt;b&gt;ETTR:&lt;/b&gt; 8 Hours&lt;BR&gt;&lt;b&gt;Areas affected:&lt;/b&gt; DSLAM Affected: EMBALENHLE
DSLAM Affected: RST1 - UMLU
DSLAM Affected: RST2 - SIPU(A33)
DSLAM Affected: SECUNDA
DSLAM Affected: SECUNDA 2
DSLAM Affected: SECUNDA IMAX&lt;BR&gt;&lt;b&gt;Progress:&lt;/b&gt; </description><ip:Type>Planned Work</ip:Type><ip:TimeDown>Thu, 28 Jun 2012 20:00:00 +0200</ip:TimeDown><ip:ETTR>8 Hours</ip:ETTR><ip:Progress></ip:Progress><ip:AreasAffected>DSLAM Affected: EMBALENHLE
DSLAM Affected: RST1 - UMLU
DSLAM Affected: RST2 - SIPU(A33)
DSLAM Affected: SECUNDA
DSLAM Affected: SECUNDA 2
DSLAM Affected: SECUNDA IMAX</ip:AreasAffected><ip:Status>New</ip:Status></item>


Thanks!

1 Answer, 1 is accepted

Sort by
0
Alexander Valchev
Telerik team
answered on 02 Jul 2012, 09:27 AM
Hi Charles,

The problem that you are experiencing is caused by the structure of the XML file. I am afraid that we do not support binding to XML with namespaces e.g. <ip:Type>Planned Work</ip:Type> 

The reason for invalid template error are the colon symbols ":" - if you remove the ip: expressions from the template and dataSource model, the error should not occur any more. The solution in this case would be to modify the server logic and return a flat XML without name spaces. For example:
//xml response
<item xmlns:ip="www.ipact.telkom-ipnet.co.za">
  <guid isPermaLink="false">NN0008585</guid>
  <pubDate>Fri, 22 Jun 2012 14:31:03 +0200</pubDate>
  <category>Planned Work</category>
  <title>Link - To perform Planned Maintenance on the Telkom Network at Secunda</title>
  <description>
   ......
  </description>
  <Type>Planned Work</Type>
  <TimeDown>Thu, 28 Jun 2012 20:00:00 +0200</TimeDown>
  <ETTR>8 Hours</ETTR>
  <Progress></Progress>
  <AreasAffected>
   .....
  </AreasAffected>
  <Status>New</Status>
</item>
 
//dataSource schema
schema: {
    type: "xml",
    data: "/item",
    model: {
        fields: {
            guid: "guid/text()",
            pubDate: "pubDate/text()",
            category: "category/text()",
            title: "title/text()",
            description: "description/text()",
            pubDate: "pubDate/text()",
            Type: "Type/text()",
            TimeDown: "TimeDown/text()",
            ETTR: "ETTR/text()",
            Progress: "Progress/text()",
            AreasAffected: "AreasAffected/text()",
            Status: "Status/text()"
        } //fields
    } // model
} //schema


Regards,
Alexander Valchev
the Telerik team
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
Tags
Data Source
Asked by
Charles
Top achievements
Rank 1
Answers by
Alexander Valchev
Telerik team
Share this question
or