More in this section

Forums / Developing with Sitefinity / Relative paths and errors for XML and XSLT in an XmlDataSource control

Relative paths and errors for XML and XSLT in an XmlDataSource control

5 posts, 0 answered
  1. Abel Braaksma
    Abel Braaksma avatar
    20 posts
    Registered:
    15 Jul 2009
    19 Apr 2010
    Link to this post
    On a page or template, you can drop an XmlDataSource from the controls section. The main settings for this are DataFile, TransformFile and/or XPath. I uploaded two files (tested them first with Microsoft's .NET XSLT transformation for working correctly) to the directory "Upload" right under the root of the project. The result is blank.

    The XML + XSLT seems an excellent addition for custom lists and external data, but some things are not clear:

    1. What is the path relative to and/or can we use absolute paths (currently none work)?
    2. What style should the path be, i.e., URI or Windows path?
    3, Can we use "~/" in the path?
    4. Is the output inserted "as-is" without escaping or post-processing of any kind?
    5. Must the output be well-formed XML, or is html, text (allowed by XSLT) also fine?
    6. Is the output already visible in edit mode, preview mode or only in published mode?
    7. How is the data caching applied?
    8. Where can I find the output of any errors?
    9. How do I turn on logging or where are xsl:messages send to?

    Sorry, quite some questions, but there doesn't seem to be any tutorial or reference out there, or any thread on the forum, so perhaps this is a good time to start one.
  2. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    19 Apr 2010
    Link to this post
    Hello Abel Braaksma,

    Thank you for using our services.

    An XmlDataSource control will not display anything by itself. In order to display the data from the data source you should have a data boundable control bound to this data source. For the path to the xml file you should use either relative paths with ~/ or absolute path. This control is just a wrapper for the ASP.NET XmlDataSource control. Its use is the same as the of the ASP.NET one - this goes for caching too. Attached is a small clip how to use the control.

    Our recommendation is however either to create User Controls or your own Custom Controls where you will handle data and then simply add those controls to the Sitefintiy toolbox.


    Sincerely yours,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  3. Abel Braaksma
    Abel Braaksma avatar
    20 posts
    Registered:
    15 Jul 2009
    19 Apr 2010
    Link to this post
    Thanks, Radoslav, for the quick reply. I meanwhile started to create my custom controls after I found out that, once you have the XmlDataSource running and the GridView connected, that you cannot create links inside the grid.

    I hoped for a quick way to basically create some custom lists (the Lists provided by Telerik, while valuable, are too limited to be of much practical use, i.e., importing a list from CSV, XML or other is missing).
  4. Radoslav Georgiev
    Radoslav Georgiev avatar
    3370 posts
    Registered:
    01 Feb 2016
    19 Apr 2010
    Link to this post
    Hello Abel Braaksma,

    You should use your own template for the grid in order to make it appear as you wish, not automatic colums. You can take a look at the demos for RadControls for ASP.NET AJAX to see how databound control are populated from XML.

    Greetings,
    Radoslav Georgiev
    the Telerik team

    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items.
  5. Abel Braaksma
    Abel Braaksma avatar
    20 posts
    Registered:
    15 Jul 2009
    19 Apr 2010
    Link to this post
    Just to answer my own question, for anyone who's wondering the same:

    1. What is the path relative to and/or can we use absolute paths (currently none work)?
    Relative and absolute paths are possible. Relative paths should be prepended with "~/".

    2. What style should the path be, i.e., URI or Windows path?
    Use forward slashes for relative paths. Not sure about absolute paths, but forward slashes should always work.

    3, Can we use "~/" in the path?
    Yes, see 1.

    4. Is the output inserted "as-is" without escaping or post-processing of any kind?
    No, there is no output inserted. This is a datasource and must be applied to a GridView or other DataBound control.

    5. Must the output be well-formed XML, or is html, text (allowed by XSLT) also fine?
    The output must be vanilla-XML to be understood by Microsoft .NET as data:
    <countries>
       <country name="Russia" abbreviation="ru" />
       <country name="Germany" abbreviation="de" />
       <country name="United States" abbreviation="us" />
    </countries>

    in the above case, the rows are the country-elements, the columns (or cells) are the attributes "name" and "abbreviation".

    6. Is the output already visible in edit mode, preview mode or only in published mode?
    No, there is no output. But if you bind it to a GridView (be sure to make the GridView be below the XmlDataSource!), then you will not see the output immediately either. Only after you click Publish or Preview, you will see the output, or an error.

    7. How is the data caching applied?
    Same as in Microsoft.NET for data sources.

    8. Where can I find the output of any errors?
    Uncaught errors will crash the entire page (but will not crash the CMS section or other pages). Just click Edit Page again and changes your settings. This is probably why the data is not immediately visible.

    9. How do I turn on logging or where are xsl:messages send to?
    No idea.
Register for webinar
5 posts, 0 answered