Copied to clipboard

Flag this post as spam?

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


  • praveity 100 posts 125 karma points
    Apr 22, 2011 @ 13:57
    praveity
    0

    <xsl:when> to determine the doc type of currentpage

    I want to determine whether the currentpage if of specific document type. 

    What I did is as below:

    <xsl:when test="$currentPage/SC_Page">
                <xsl:for-each select="$currentPage/*[@isDoc]">
                  <xsl:call-template name="renderChildContent">
                  </xsl:call-template>
                </xsl:for-each>
    </xsl:when>

    where SC_Page is document type with id= 1054 of the current page. This code doesn't work for me. I couldn't access the code within it.

    Howeve I have found another workaround i.e.

    <xsl:when test ="$currentPage/@nodeType = 1054">
                <xsl:for-each select="$currentPage/parent::*[@isDoc]/*[@isDoc]">
                  <xsl:call-template name="renderChildContent">
                  </xsl:call-template>
                </xsl:for-each>
    </xsl:when>

    Can anyone please explain why the first code snippet doesnt work???

  • Tom Fulton 2030 posts 4998 karma points c-trib
    Apr 22, 2011 @ 14:04
    Tom Fulton
    1

    Hi,

    You can use:

    <xsl:when test="$currentPage/self::SC_Page">

    or

    <xsl:when test="local-name($currentPage) = 'SC_Page'">

    More info here

    Another approach is to use match templates, although it takes some time to get used to.  Great blog post on it here.

    Hope this helps,
    Tom

  • praveity 100 posts 125 karma points
    Apr 22, 2011 @ 14:09
    praveity
    0

    Hi Tom,

    Thanks for your fast response.

    I tried it and it worked for me.

     

Please Sign in or register to post replies

Write your reply to:

Draft