Copied to clipboard

Flag this post as spam?

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


  • Luyolo Mgodi 71 posts 120 karma points
    Oct 03, 2013 @ 00:20
    Luyolo Mgodi
    0

    Getting Images from a media folder

    Hi,

    I have a gallery that is classified by Categories. Each category has its own folder to get images from I have written the XSLT below and Im getting errors.I am on Umbraco 6.1.5

    Below is the error that I am getting and also the XSLT.

     

    Skip testing (ignore errors)

    Hide ErrorsError occured

    System.Xml.Xsl.XslTransformException: Expression must evaluate to a node-set. 
    at System.Xml.Xsl.Runtime.XsltConvert.EnsureNodeSet(IList`1 listItems) 
    at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime, String currentPage) 
    at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at Execute(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlSequenceWriter results) 
    at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, XmlWriter results, XmlResolver documentResolver) 
    at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results) 
    at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)

    xml version="1.0" encoding="UTF-8"?>
    DOCTYPE xsl:stylesheet [ ENTITY nbsp " "> ]>
    <xsl:stylesheet 
      version="1.0" 
      xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
      xmlns:msxml="urn:schemas-microsoft-com:xslt"
      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" xmlns:Examine="urn:Examine" xmlns:ucomponents.cms="urn:ucomponents.cms" xmlns:ucomponents.dates="urn:ucomponents.dates" xmlns:ucomponents.media="urn:ucomponents.media" xmlns:ucomponents.members="urn:ucomponents.members" xmlns:ucomponents.nodes="urn:ucomponents.nodes" xmlns:ucomponents.search="urn:ucomponents.search" xmlns:ucomponents.strings="urn:ucomponents.strings" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets Examine ucomponents.cms ucomponents.dates ucomponents.media ucomponents.members ucomponents.nodes ucomponents.search ucomponents.strings ">
    
    
    <xsl:output method="xml" omit-xml-declaration="yes"/>
    
    <xsl:param name="currentPage"/>
    
    <xsl:template match="/">
      <xsl:param name="currentPage"/>
    
    <xsl:for-each select="$currentPage/GalleryCategory">
      <xsl:variable name="mediaFolderId" select="number(current()/mediaFolderId)" />
     <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($mediaFolderId, true())"/>
      
      <div id="single_gallery_container">
           <div id="gallery_container">
                   <h3> <xsl:value-of select="current()/nodeName" disable-output-escaping="yes"/>h3>
               <xsl:for-each select="$mediaItems/Image">
             <xsl:variable name="picFile" select="umbracoFile"/>
                   <div class="gallery_column">
                          <div class="gallery_img_container">
                                  <div class="gallery_img">
                                  <img>
                  <xsl:attribute name="src">
                    <xsl:text>/umbraco/ImageGen.ashx?image=xsl:text>
                    <xsl:value-of select="$picFile"/>
                    <xsl:text>&width=150&height=98%&constrain=truexsl:text>
                  xsl:attribute>
                    
                img>
                                  div>
                                   <div class="gallery_shadow"><img src="/images/box_shadow.png" width="100%" />div>
                          div>
                   div>
               xsl:for-each>
          div>
           <div id="back_to_top" class="col-full"><a href="#">back to topa>div>
      div>
    
    xsl:for-each>
    xsl:template>
    
    xsl:stylesheet>
  • Dennis Aaen 4500 posts 18255 karma points admin hq c-trib
    Oct 03, 2013 @ 08:05
    Dennis Aaen
    0

    Hi Luyolo,

    Maybe you could get some inspiration from my code. I donĀ“t have the for-each loop becase I only print images from the folder selected on the current page.

    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE xsl:stylesheet [
      <!ENTITY nbsp "&#x00A0;">
    ]>
    <xsl:stylesheet
     version="1.0"
     xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
     xmlns:msxml="urn:schemas-microsoft-com:xslt"
     xmlns:umbraco.library="urn:umbraco.library"
     exclude-result-prefixes="msxml umbraco.library">

      <xsl:output method="xml" omit-xml-declaration="yes"/>
      <xsl:param name="currentPage"/>
      <xsl:template match="/">
       
        <xsl:variable name="images" select="$currentPage/pictureGallery"/>

          <xsl:variable name="mediaItems" select="umbraco.library:GetMedia($images, true())"/>
          <div class="galleryPage">
              <h2>
                  <xsl:value-of select="$currentPage/heading"/>
              </h2>
              <xsl:for-each select="$mediaItems/Image">
            <xsl:variable name="picFile" select="umbracoFile"/>
             
              <div class="thumb">

              <!-- this can be used to link to the image -->

              <xsl:element name="a">
                  <xsl:attribute name="href">
                  <xsl:value-of select="./umbracoFile" />
                </xsl:attribute>
                   <xsl:attribute name="title">
                  <xsl:value-of select="./@nodeName" />
                </xsl:attribute>

                <!-- the rel and id attribute can be used to fire fancybox -->

                <xsl:attribute name="id">
                  <xsl:text>gallery</xsl:text>
                </xsl:attribute>

                <xsl:attribute name="rel">
                    <xsl:text>lightbox[galleryImages]</xsl:text>
                </xsl:attribute>

                <img>
                  <xsl:attribute name="src">
                    <xsl:text>/ImageGen.ashx?image=</xsl:text>
                    <xsl:value-of select="$picFile"/>
                    <xsl:text>&amp;width=146&amp;height=98%&amp;constrain=true</xsl:text>
                  </xsl:attribute>
                </img>
                 

              </xsl:element>
            </div>
      
          </xsl:for-each>
          </div>
      </xsl:template>
    </xsl:stylesheet>

    But I hope this post can inspire you to find the right solution.

    /Dennis

Please Sign in or register to post replies

Write your reply to:

Draft