Copied to clipboard

Flag this post as spam?

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

  • Mladen Macanovic 22 posts 45 karma points
    Nov 05, 2010 @ 12:54
    Mladen Macanovic

    reading xml file with xslt


    I'm completely new to umbraco and i'm already stucked. I want to create xml file that holds the information about page name, link to that page, description and a an image.

    This is a simple structure of that xml file. For simplicity it has only one node for now.

    <node id="1" nodeName="destination">
        <data alias="navName">
        <data alias="description">
            <![CDATA[Spend unique holidays in the middle of the Adriatic sea ? Book a lighthouse!]]>
        <data alias="link">
        <data alias="image">


    What I don't know is how to read this from the xslt. Where do I put the xml file regarding of the xslt file? I have put it in the same dir as the xslt file. Is this the right thing to do?

    Please any help is appreciated.

  • Happyfanaticsalsero 59 posts 81 karma points
    Nov 05, 2010 @ 13:28


    It seems to me you want to display details from nodes in your content. You don't need to access an external xml for that, you can access the umbraco xml from within the xslt. Just choose the template "subpages from a changeable source" or the template "subpages from the current page" to get a grasp of how the XSLT will list the sub pages.

    The sub pages are actually all xml nodes which you can further drill down to in your xslt. Use the "visualise xslt" function on the right top of your xlst page and choose a node on which you can perform the xslt. If you use a "<xsl:copy-of select="."/> you will copy the xml of the current node you're on. If you do that under your for-each, you will list the xml for each node under your current (or chosen one). Please note that you might need to encode the result (checkbox on visualize xslt).

    For example, if you have a document type (in umbraco 4.5.2) of type "destination" as in your example, you could

    - do a foreach of $currentpage/destination

    in the foreach do a xsl:value-of select="./description" etc.

    I hope this might help you getting on the right track, if it's a bit too cryptic let me know.

    Kind regards,


  • Happyfanaticsalsero 59 posts 81 karma points
    Nov 05, 2010 @ 13:42

    If you're looking for a way to export existing nodes as xml, there are packages that can do that:

  • Mladen Macanovic 22 posts 45 karma points
    Nov 05, 2010 @ 14:27
    Mladen Macanovic

    Thank you, I have managed to create links based on the document type properties as you proposed.

    Now I'm stucked as I dont know how to show the thumbnail image with the link. What is the right way to do this?

    Also there is another problem, each of this pages will have 4 different languages, so I don't know is this the right way to do this. Do I need to have different page for each one of these language or I can do this dynamicaly?

  • Happyfanaticsalsero 59 posts 81 karma points
    Nov 05, 2010 @ 14:43

    For a solution on multiple language sites there are different approaches. Generally in the Umbraco community people will use a different sub or child domain (; yourdomain/nl etc) and build several homepage nodes with different host headers (right click on a homepage node and set the host header for your domain and language). More about multi language sites can be found in this excellent tutorial (subscription of 19€ to Umbraco TV required):,-domains-and-languages. If you don't want to pay for the subscription just search on this forum for some approaches.

    To show a thumbnail: that depends on the data type you used. If it's a media picker, you'll want to use some umbraco library extension in your xslt. Just click the button for the xslt:value-of, select extensions, select umbraco library and select the GetMedia. I think you'll get the hang of how to do that pretty quickly. Otherwise just search the forum for GetMedia.

    If it's a upload data type, it might be a bit different. So if you still need some advise reply with the exact data type (and/or render control) you use.

    It might be useful if you would post your current XSLT as well (use the code block function).


  • Mladen Macanovic 22 posts 45 karma points
    Nov 05, 2010 @ 15:00
    Mladen Macanovic

    ok here is the xslt code.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [ <!ENTITY nbsp "&#x00A0;"> ]>
      xmlns:umbraco.library="urn:umbraco.library" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
    umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes
    Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings
    Exslt.ExsltSets "

    <xsl:output method="xml" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- The fun starts here -->
    <xsl:for-each select="$currentPage/ACDestinations [@isDoc and string(umbracoNaviHide) != '1']">
      <div class="Izdvojeno" id="Hoteli">
                <xsl:attribute name="src">
                   <xsl:value-of select="./thumbnail" />             
             <a href="{umbraco.library:NiceUrl(@id)}">
              <h3> <xsl:value-of select="@nodeName" /></h3>
               <xsl:value-of select="./description" />


    As you can see I try to fill the path to the image by stating the './thumbnail' property but nothing happens as I dont' know where do I put these images.

  • Happyfanaticsalsero 59 posts 81 karma points
    Nov 05, 2010 @ 15:33

    xslt:value-of of the thumnail property won't do you much good.

    I would probably go with a html img build up from properties from your thumbnail field.

    You should do a copy-of first to see what kind of xml lurks behind this "thumbnail" field you've got; but to my opinion this will probably do the trick:

     <xsl:if test="./thumbnail">
       <xsl:variable name="url" select="./thumbnail/umbracoFile" />
       <xsl:variable name="width" select="./thumbnail/umbracoWidth" />
       <xsl:variable name="height" select="./thumbnail/umbracoHeight" />
       <xsl:variable name="alt" select="./thumbnail/altText" />
       <img src="{$url}" width="{$width}" height="{$height}" alt="{$alt}" />
Please Sign in or register to post replies

Write your reply to: