Copied to clipboard

Flag this post as spam?

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


  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 02, 2011 @ 13:47
    Fuji Kusaka
    0

    Include XSLT within another XSLT

    Hi Guys,

     

    Am trying to get include a XSLT withing another one but getting some error message. I tried some previous post but still cant get it working.

    This is my main XSLT

    <xsl:param name="currentPage"/>
    <xsl:include href="slideshow.xslt"/>

    <xsl:template match="/">
      
     <!-- start writing XSLT -->
    <xsl:for-each select="$currentPage">

        <div class="content">
              <h2 class="acc_trigger"><a href="#">Introduction</a></h2>
                 <div class="acc_container">
                   <div class="block">
                       <xsl:value-of select="member_Introduction" disable-output-escaping="yes"/>
                   </div>
                  </div>
              <h2 class="acc_trigger"><a href="#">Slideshow</a></h2>
                 <div class="acc_container">
                   <div class="block">
                      

    <!-- <xsl:include href="slideshow.xslt"/>  -->


                   </div>
                  </div>
            
        </div><!-- End of Content -->


    </xsl:for-each>

    </xsl:template>

     

    And my Include XSLT Slideshow

    <!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" 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" 
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">




    <xsl:template match="/">

    <!-- start writing XSLT -->
      
      
    Hello World there!!!
      


    </xsl:template>

    </xsl:stylesheet>

     

    Whenever i want to move my include xslt in between the slideshow container i get an error message and everything just crash.

    Anyone can point be to the right direction??

     



  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 02, 2011 @ 14:09
    Tom Fulton
    2

    Hey Fuji,

    It might be because your include and master XSLT file both include the same template (<xsl:template match="/">) - you should probably remove this from your included XSLT and create a template you can call by name or match condition.

    Check out this article on Chriztian's blog for some examples:  <xsl:include> or <xsl:import> ?

    -Tom

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Aug 02, 2011 @ 14:20
    Chriztian Steinmeier
    1

    Hi Fuji,

    You can only include (or import) at the root level, so you can't put the <xsl:include> instruction inside another template.

    Effectively the templates from the included file gets inserted where you put the include instruction, so you need to be careful with duplicated templates. But you can use it for great things - read the article Tom linked to (thanks Tom!) for further goodies. 

    /Chriztian

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 02, 2011 @ 15:20
    Fuji Kusaka
    0

    Hi Guys,

    I tried your blog as suggested by Tom. But still not getting the output. This is how i proceed.

    Main XSLT

    <xsl:param name="currentPage"/>

    <xsl:template match="/">
       
     <!-- start writing XSLT -->
    <xsl:for-each select="$currentPage">

        <div class="content">
              <h2 class="acc_trigger"><a href="#">Introduction</a></h2>
                 <div class="acc_container">
                   <div class="block">
                       <xsl:value-of select="member_Introduction" disable-output-escaping="yes"/>
                   </div>
                  </div>
              <h2 class="acc_trigger"><a href="#">Geneal</a></h2>
                 <div class="acc_container">
                   <div class="block">
                       <xsl:value-of select="member_general" disable-output-escaping="yes"/>
                   </div>
                  </div>
              <h2 class="acc_trigger"><a href="#">Flags</a></h2>
                 <div class="acc_container">
                   <div class="block">     

    <
    xsl:apply-templates select="$currentPage/test" />
                     
                   </div>
                  </div>
            
          
        </div><!-- End of Content -->


    </xsl:for-each>

    </xsl:template>
        
        
        <xsl:template match="test">
            <xsl:apply-templates select="." mode="media" />
        </xsl:template>    
       
         <xsl:include href="slideshow.xslt"/>

     

    And Include Slideshow XSLT

    <?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" 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"
      exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">

        <xsl:template match="*" mode="media">
             Trying to get the Include working
        </xsl:template>

     </xsl:stylesheet>

     

    I just want the Text to appear in the first place then i will carry on this the functionality of the slideshow xslt. Any advise on this guys??

     

    //fuji

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 02, 2011 @ 20:34
    Fuji Kusaka
    0

    Ive been struggling to get this working but seems like am missing  something there....still cant get any output

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 02, 2011 @ 22:37
    Tom Fulton
    0

    Hi Fuji,

    I would suspect your match="test" template isn't getting called.  What exactly is $currentPage/test?  Is there a property called test?

    Not sure your exact situation, but if you are wanting to list Images from a Media Folder, you could try something like:

                 <h2 class="acc_trigger"><a href="#">Flags</a></h2>
                 <div class="acc_container">
                   <div class="block">     
     
                   <xsl:apply-templates select="umbraco.library:GetMedia(0000,true())/Image" mode="media" />
                    
                   </div>
                  </div>

    Replacing 0000 with the ID of the Media Folder (or a variable containing it).

    -Tom

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 03, 2011 @ 04:55
    Fuji Kusaka
    0

    Hi Tom,

     

    Actually i would like to have a loop in my slideshow XSLT which will loop in the media folder. So at the moment I need to add the include somewhere in the main xslt.

    To put you more in the figure, the main xslt consists of several tabs which by default has a display:none; . In one of them it has been asked by the client to fetch for images in the media folder. Thats the reason why I want to make use of <xsl:include href="" />, but not sure of how to achieve this.

     

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 03, 2011 @ 14:01
    Tom Fulton
    0

    What I posted above should work then, just replace 0000 with the media folder ID or property containing it

     <xsl:apply-templatesselect="umbraco.library:GetMedia(0000,true())/Image"mode="media"/>

    It should then call your template in the include file for each Image that is found in the folder

    -Tom

  • John 27 posts 49 karma points
    Aug 03, 2011 @ 15:45
    John
    0

    Could you not include the other stylesheet as a macro?

     

    <xsl:variable name="macro">
    <xsl:text><![CDATA[<?UMBRACO_MACRO macroAlias="slideshow" ></?UMBRACO_MACRO>]]></xsl:text>
    </xsl:variable>
    <xsl:value-of select="umbraco.library:RenderMacroContent($macro,$currentPage/@id)" disable-output-escaping="yes"/>
  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 04, 2011 @ 15:02
    Fuji Kusaka
    0

    Hi Tom,

     

    Yes I got this part working, now i need to get the page to display the images from my media section. However this is quiet tricky since i need to check if a node is related to sepcific media id under my media section.

    Am not sure if you are getting my point though.

    //fuji

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Aug 04, 2011 @ 22:28
    Tom Fulton
    0

    Hmm, not sure I follow, what do you mean by if a node is related to a media ID?

  • Fuji Kusaka 2203 posts 4220 karma points
    Aug 04, 2011 @ 22:38
    Fuji Kusaka
    0

    Got it sorted out !!!!! So basically i have my main xslt and include in it where the include will look for its slideshow gallery and will loop through it to get all the images.

    But thanks again for the help on how to make the include working Tom.

    //fuji

Please Sign in or register to post replies

Write your reply to:

Draft