Copied to clipboard

Flag this post as spam?

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


  • vaibhav 119 posts 139 karma points
    Mar 28, 2011 @ 08:31
    vaibhav
    0

    how to use recursive="true" in xslt

    Hello,

    I have properties in home page which are propely shown in home page with bellow xslt , but when i use this same xslt in child pages then properties values are not shown in child pages .....

    How to show it ?

    Can we something like recursive="true" in the xslt so that it will be shown in child pages also (i tried putting recursive="true" in xslt but its showing error in that line where i put recursive="true".)

    Bellow is my 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" xmlns:tagsLib="urn:tagsLib" xmlns:BlogLibrary="urn:BlogLibrary"
      exclude-result-prefixes="msxml
    umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes
    Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings
    Exslt.ExsltSets tagsLib BlogLibrary "
    >


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

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

      <xsl:choose>
    <xsl:when test="$currentPage/solutionblock1_image !=''">
                <div id="solutionsBlock3">
                      <div id="newsiamge"><img src="{$currentPage/solutionblock1_image}" recursive="true" width="115px" height="90px"/></div>
                      <div id="BlockContent">
                          <div id="bold"> <xsl:value-of select="$currentPage/solutionBlock1_Header"/></div>
                          <div id="normal"><xsl:value-of select="umbraco.library:TruncateString($currentPage/solutionBlock1_content, 45,'')" disable-output-escaping="yes"/>
                                <a href="{$currentPage/solutionBlock1_link}"> >> </a>
                          </div>
                      </div>
                </div>
    </xsl:when>
    <xsl:otherwise>
                <div id="solutionsBlock2">
                        <div id="BlockHeader"><xsl:value-of select="$currentPage/solutionBlock1_Header" /></div>
                        <div id="BlockContent1">
                          <xsl:value-of select="umbraco.library:TruncateString($currentPage/solutionBlock1_content, 120,'')" disable-output-escaping="yes"/>
                           <a href="{$currentPage/solutionBlock1_link}"> >> </a>
                        </div>
               </div>
    </xsl:otherwise>
    </xsl:choose>

    </xsl:template>

    </xsl:stylesheet>

    This is my xslt ...

     

  • Sebastian Dammark 583 posts 1407 karma points
    Mar 28, 2011 @ 09:07
    Sebastian Dammark
    1

    Hi

    If you want to get something from a parent page or even higher up the structure you can use the following:

    <xsl:variable name="myValue" select="$currentPage/ancestor-or-self::*[@isDoc]/myproperty" />

    The code above gets the property 'myproperty' from current page or any parent page.

  • Chriztian Steinmeier 2798 posts 8788 karma points MVP 8x admin c-trib
    Mar 28, 2011 @ 12:52
    Chriztian Steinmeier
    2

    Hi vaibhav,

    To get the exact equivalent of recursive=true in XSLT you need to do the following:

    <xsl:value-of select="$currentPage/ancestor-or-self::*[normalize-space(propertyName)][1]/propertyName" />

    - returns the first ancestor (or self) that has a value in the "propertyName" property.

    /Chriztian

Please Sign in or register to post replies

Write your reply to:

Draft