Copied to clipboard

Flag this post as spam?

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


  • shine 43 posts 83 karma points
    May 29, 2013 @ 07:07
    shine
    0

    xslt dispaly all the header

    here is my code of xslt thet i want to see only current page header but this xslt display all the header so how can i solve this?

    <?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:output method="html" omit-xml-declaration="yes"/>

    <xsl:param name="currentPage"/>

    <xsl:template match="/">

    <!-- start writing XSLT -->
       
        <xsl:for-each select="$currentPage/SEGWTextPage">
       
       
        <xsl:choose>
    <xsl:when test="pageheaderLink != ''">
     <a >            
               
                    <xsl:attribute name="class">
                      <xsl:text></xsl:text>
                    </xsl:attribute>               
                   
                    <xsl:attribute name="href">                   
                       <xsl:value-of select="pageheaderLink"/>                                 
         </xsl:attribute><h2 style="text-align:left;"><strong style=""></strong> <xsl:value-of select="pageheader"/></h2>            
         
                </a>
    </xsl:when>
    <xsl:otherwise>
        <h2 style="text-align:left;"><strong style=""></strong><xsl:value-of select="pageheader"/></h2>
    </xsl:otherwise>
    </xsl:choose>
        </xsl:for-each>
       
    </xsl:template>

    </xsl:stylesheet>

  • Chriztian Steinmeier 2800 posts 8791 karma points MVP 8x admin c-trib
    May 29, 2013 @ 08:37
    Chriztian Steinmeier
    100

    Hi shine,

    If all you want is output from $currentPage, then you don't need to use a for-each - when you're inside a for-each, all your XPaths are in the context of the current node of the loop, so when you say "pageheader" that will take the header from the page currently in the loop - you can always start your XPaths with $currentPage to pick something from the current page being *rendered*, though.

    I suggest you try this:

    <?xml version="1.0" encoding="utf-8" ?>
    <xsl:stylesheet
        version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:umbraco.library="urn:umbraco.library"
        exclude-result-prefixes="umbraco.library"
    >
    
        <xsl:output method="html" indent="yes" omit-xml-declaration="yes" />
    
        <xsl:param name="currentPage" />
    
        <xsl:template match="/">
            <xsl:choose>
                <xsl:when test="normalize-space($currentPage/pageheaderLink)">
                    <a href="{$currentPage/pageheaderLink}">
                        <xsl:apply-templates select="$currentPage/pageheader" />
                    </a>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:apply-templates select="$currentPage/pageheader" />
                </xsl:otherwise>
            </xsl:choose>
        </xsl:template>
    
        <xsl:template match="pageheader">
            <h2>
                <xsl:value-of select="." />
            </h2>
        </xsl:template>
    
    </xsl:stylesheet>

    /Chriztian

  • shine 43 posts 83 karma points
    May 29, 2013 @ 12:40
    shine
    0

    Thank you very much Chriztian its work fine....................

Please Sign in or register to post replies

Write your reply to:

Draft