XML Data source + Basic Repeater. No data shows .

Susanne Hou asked on December 21, 2015 09:33

Hello.

I'm working on a website that needs to display some weather information, which is in the form of an XML document. So I've used an XML Data Source web part along with a Basic Repeater to display the data. However, I cannot get the Repeater to display any data at all. The data comes in this format:

<?xml version="1.0" encoding="iso-8859-1"?>
<DKMaster>
   <Provider>
      DMI
   </Provider>
   <AnalysisTime>
      <year>
         2015
      </year>
      <month>
         12
      </month>
      <day>
         14
      </day>
      <hour>
         11
      </hour>
      <minute>
         28
      </minute>
      <time>
         UTC
      </time>
   </AnalysisTime>
   <parameter>
      <name>
         Winddirection
      </name>
      <unit/>
      <value>
         200.000000
      </value>
   </parameter>
   <parameter>
      <name>
         WindSpeed
      </name>
      <unit>
         knob
      </unit>
      <value>
         22.000000
      </value>
   </parameter>
   <parameter>
      <name>
         WindMaximum
      </name>
      <unit>
         knob
      </unit>
      <value>
         22.000000
      </value>
   </parameter>
   <parameter>
      <name>
         WindMinimum
      </name>
      <unit>
         knob
      </unit>
      <value>
         22.000000
      </value>
   </parameter>
   <parameter>
      <name>
         Temperature
      </name>
      <unit>
         Celcius
      </unit>
      <value>
         10.727000
      </value>
   </parameter>
   <parameter>
      <name>
         Dewpoint
      </name>
      <unit>
         Celcius
      </unit>
      <value>
         4.298892
      </value>
   </parameter>
   <parameter>
      <name>
         TemperatureMaximum
      </name>
      <unit>
         Celcius
      </unit>
      <value>
         10.998000
      </value>
   </parameter>
   <parameter>
      <name>
         TemperatureMinimum
      </name>
      <unit>
         Celcius
      </unit>
      <value>
         10.006000
      </value>
   </parameter>
   <parameter>
      <name>
         QNH
      </name>
      <unit>
         HPa
      </unit>
      <value>
         1023.664537
      </value>
   </parameter>
   <parameter>
      <name>
         Visibility
      </name>
      <value>
         CAVOK
      </value>
   </parameter>
   <parameter>
      <name>
         Weather
      </name>
      <value>
      </value>
   </parameter>
   <parameter>
      <name>
         Cloud1
     </name>
      <value>
      </value>
   </parameter>
   <parameter>
      <name>
         Cloud2
      </name>
      <value>
      </value>
   </parameter>
   <parameter>
      <name>
         Cloud3
      </name>
      <value>
      </value>
   </parameter>
</DKMaster>

However, I have also tried with a very simple XML document containing two entries of a book, and had no luck with that either.

In the web part properties for the basic repeater, under No data Behavior, I have selected the No Record Found text to be No Data Found. I have verified that it does indeed show this text when I enter a non-valid XML document. Image Text

However, when I link the XML Data source web part with the basic repeater, no data is shown. It looks like this:

Image Text

I've tried with two different XML documents and two instances of a basic repater + XML data source, and no data shows up on any of them. However, it does not show the message that no data is found.

What am I doing wrong?

Correct Answer

Juraj Ondrus answered on December 21, 2015 11:37

Hi,

I am glad to see some progress. I would try using absolute URL to given XML file if it is stored as a media file or in general an external file. Otherwise, I would use relative path from the root of the web site using the tilde (~) at the beginning.

0 votesVote for this answer Unmark Correct answer

Recent Answers


Juraj Ondrus answered on December 21, 2015 09:36

Hi,

What are the repeater settings for connecting to the data source? Recently I had similar issue where in the "Data source name" was used the data source web part title and not the data source web part ID.

0 votesVote for this answer Mark as a Correct answer

Susanne Hou answered on December 21, 2015 10:15

Hello Juraj

Yes, I checked that the data source web part title is used in the Data Source Name. I checked again now, and both seems to be correct.

See below for repeater settings.

Image Text

I have not set any transformations, since i couldnt figure out if it was necessary or not -a nd I couldnt find one that seemed to be related to XML.

0 votesVote for this answer Mark as a Correct answer

Juraj Ondrus answered on December 21, 2015 10:28

Thank you for that!

You need to specify a transformation so the repeater know what data from the source should be displayed and also how - in the transformation you also specify the look&feel of the data that should be presented by the repeater.

0 votesVote for this answer Mark as a Correct answer

Susanne Hou answered on December 21, 2015 11:18 (last edited on December 21, 2015 11:20)

Oh I completely missed out on that! I made a quick new tranformation in XSLT, like this:

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:template match="/">
      <html>
      <body>
      <h2>Weather Report</h2>
        <table border="1">
          <tr bgcolor="#9acd32">
            <th style="text-align:left">Provider</th>
            <th style="text-align:left">AnalysisTime</th>
        <th style="text-align:left">parameter</th>
    <th style="text-align:left">unit</th>
    <th style="text-align:left">value</th>

          </tr>
          <xsl:for-each select="DKMaster">
          <tr>
            <td><xsl:value-of select="Provider"/></td>
            <td><xsl:value-of select="AnalysisTime"/></td>

    <xsl:for-each select="parameter">
            <tr>
            <td><xsl:value-of select="name"/></td>
            <td><xsl:value-of select="unit"/></td>
            <td><xsl:value-of select="value"/></td>
            </tr>
            </xsl:for-each>
          </tr>
          </xsl:for-each>
        </table>
      </body>
      </html>
    </xsl:template>
    </xsl:stylesheet>

I verified it to display the data, and although it doesnt display it entirely corretcly, it does display some data. It looks like this:

Image Text

I tried making a new transformation, and insert this as XSLT tranformation. However, it comes out looking like this:

Image Text

I'm wondering if I connected to the XML document correctly. I uploaded the files to a media library created for that specific website.

Image Text

0 votesVote for this answer Mark as a Correct answer

   Please, sign in to be able to submit a new answer.