Copied to clipboard

Flag this post as spam?

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


  • AlexR 39 posts 61 karma points
    May 07, 2010 @ 12:24
    AlexR
    0

    How to return different node sets by condition?

    If imgId is empty I want get empty node set, but GetMedia  return error.

    How to return something like next:

    <xsl:variable name="img" select="if(number($imgId), umbraco.library:GetMedia($imgId, false()), /.. /* empty node-set */ )" />

     

     

  • Tobias Neugebauer 52 posts 93 karma points
    May 07, 2010 @ 12:52
    Tobias Neugebauer
    0

    Hi,

    you can assign a variable by condition like this:

    <xsl:variable name="myVar">
        <xsl:choose>
            <xsl:when test="yourCondition">
                 <xsl:select .../>
            </xsl:when>
            <xsl:otherwise>
                 <xsl:select .../>
            </xsl:otherwise>
        </xsl:choose>
    </xsl:variable>

    Hope this helps :)

    Toby

  • AlexR 39 posts 61 karma points
    May 11, 2010 @ 07:36
    AlexR
    0

    This  isn't help. This return not node set as result.

    for example

    <xsl:variable name="img" select="umbraco.library:GetMedia($imgId, false())" />

    return node set, but

    <xsl:variable name="img">
      <xsl:value-of select="umbraco.library:GetMedia($imgId, false())" />
    <xsl:variable>

    doesn't return node set. The second return XML that you can parse to node set.

  • Tobias Neugebauer 52 posts 93 karma points
    May 11, 2010 @ 08:13
    Tobias Neugebauer
    0

    Hi,

    sorry that didn't do it! Did you try xsl:copy-of instead of xsl:value-of maybe this will do the trick:

    <xsl:variable name="img">
     
    <xsl:copy-of select="umbraco.library:GetMedia($imgId, false())" />
    <xsl:variable>

    Cheers, Toby

Please Sign in or register to post replies

Write your reply to:

Draft