Copied to clipboard

Flag this post as spam?

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


  • Vishal G.P 62 posts 122 karma points
    Feb 26, 2012 @ 18:18
    Vishal G.P
    0

    xslt error node-set

    hey guys..

     

    i have a very strange xslt error which i cannot debug properly...

    Below is my code.. I'm just trying to put a page in a variable... which i'm trying to use later...

    <xsl:variable name="currentSection">
                <xsl:choose>
                  <xsl:when test="name($currentPage) = 'DienstPage'">
    <
    xsl:value-of select="$currentPage"/>
    </
    xsl:when>               <xsl:otherwise>
    <
    xsl:value-of select="$currentPage/parent::DienstPage"/>
    </
    xsl:otherwise>             </xsl:choose> </xsl:variable>

    But my slightest use of that variable currentSection gives me the following error:

    To use a result tree fragment in a path expression, first convert it to a node-set using the msxsl:node-set() function

    if i even tries to write out this codesnippet:

    <xsl:value-of select="$currentSection/@nodeName"/>
    

    or even after searching this forum:

    <xsl:value-of select="msxml:node-set($currentSection)/@nodeName"/>
    

     

    So what is the problem with my variable.. i just want the page that has been assigned to the variable currentSection.

    Hope some of you can help me out..

     

    thanks in advance

     

     

  • Nigel Wilson 945 posts 2077 karma points
    Feb 26, 2012 @ 19:14
    Nigel Wilson
    0

    Hi Wiske

    If you are trying to get the document alias maybe try $currentPage/name() - I haven't tested this but think I've got it right.

    If you are trying to get the name of the page (ie what you named it when creating it) then you should use @nodeName

    Hope this helps.

    Nigel

  • Chriztian Steinmeier 2800 posts 8790 karma points MVP 8x admin c-trib
    Feb 26, 2012 @ 20:09
    Chriztian Steinmeier
    0

    Hi Wiske80,

    The error you get is because your variable is a string (because value-of will always return a string) when you try to use it - the best way to do what you're trying is to select it like this:

    <xsl:variable name="currentSection" select="$currentPage/ancestor-or-self::DienstPage[1]" />

    This will select $currentPage if it's of type DienstPage - otherwise it will select the first ancestor (parent, parent's parent etc.) that is of type DienstPage

    /Chriztian

  • Vishal G.P 62 posts 122 karma points
    Feb 26, 2012 @ 21:48
    Vishal G.P
    0

    thanks chriztian... your pointers helped me alot...

Please Sign in or register to post replies

Write your reply to:

Draft