Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at

  • praveity 100 posts 125 karma points
    Apr 05, 2011 @ 11:29

    how to query datatable return from xsltextension in xslt

    Hi to all,

    I am trying to develop a xslt extension which returns datable. The datatable consists of two columns like

    col A and col B. I would like to populate colA based on colB value.

    How could I do this in xslt??

    Is it possible to have datatable as return value in xslt??

  • Ismail Mayat 3498 posts 6826 karma points admin mvp c-trib
    Apr 05, 2011 @ 13:11
    Ismail Mayat


    xslt extensions return xpathnavigator or simple types like string integer etc you cannot return a datatable. You can create xml representation of your data and return that as xpathnavigator.



  • praveity 100 posts 125 karma points
    Apr 05, 2011 @ 13:34


    Thanks for your earlier reply. 

    I will work on it and let you know.

  • praveity 100 posts 125 karma points
    Apr 06, 2011 @ 08:44

    I found the solution. Here is the code snipet 


    private XPathNavigator getTagCloud()
            var sqlHelper = DataLayerHelper.CreateSqlHelper(umbraco.GlobalSettings.DbDSN);
            umbraco.DataLayer.IRecordsReader resultSet = sqlHelper.ExecuteReader("select * from tagcloud");
            XmlDocument doc = new XmlDocument();
            XmlElement root = doc.CreateElement("Tags");
            XPathNavigator nav;
            if (resultSet.HasRecords)
                while (resultSet.Read())
                    XmlElement ele = doc.CreateElement("Tag");
                    ele.SetAttribute("id", resultSet.GetInt("Id").ToString());
                    ele.SetAttribute("value", resultSet.GetString("value"));
                    ele.SetAttribute("hitCount", resultSet.GetInt("hitCount").ToString());
                nav = doc.CreateNavigator();
                return nav;
                return doc.CreateNavigator();        

    Then in xslt i have

    <xsl:for-each select="TagCloudHelper:GetTagCloud(10)/descendant-or-self::Tag">
    <xsl:value-of select="@value"/>
    <xsl:value-of select="@hitCount"/>


    Now I could use the whole table values in my xslt. 

    Hope this help.



Please Sign in or register to post replies

Write your reply to:

Draft is the community mothership for Umbraco, the open source cms. With a friendly forum for all your questions, a comprehensive documentation and a ton of packages from the community. This site is running Umbraco version 7.3.1