0

I have the following condition (I removed some items not to let the long code):

<xsl:when test="$Rows[1]/@Style='Results-List'">
   <ul>
      <xsl:for-each select="$Rows">
         <li>
            <a href="/{@FileRef}" title="{$Data} - {@Title}">
               <xsl:choose>
                 <xsl:when test="(@PublishingRollupImage = '')">
                   <img src="/Util/Imagens/image-test.jpg" />
                 </xsl:when>
                 <xsl:otherwise>
                   <xsl:value-of select="@PublishingRollupImage"  />
                 </xsl:otherwise>
               </xsl:choose>
            </a>
         </li>
      </xsl:for-each>
   </ul>
</xsl:when>

In one of the results @PublishingRollupImage field is filled, but always in the first condition.

I use a list of pages sharepoint for searching and the column is of type "Publishing Image"

I've tried to do with xsl:if however, believe that I'm doing the wrong condition. Can anyone help me?

3
  • Your condition looks correct if you want to implement some kind of default behavior if @PublishingRollupImage is an empty string (or does not exist at all). You don't need the parentheses, though. Are you sure that the attribute @PublishingRollupImage is in the current node when the condition is being tested? Another thing: in one case you return a string in the other case you return a HTML fragment. Is this intentional? Could you extend your example by adding the embracing tags using the result of your <choose> environment? May 26, 2014 at 15:03
  • Yes it is intentional on a result you see a string and a variable into another come. I added in the variable @PublishingRollupImage and returns the value. But the column is filled. I'll update the example to see if improvements in understanding May 26, 2014 at 17:47
  • The use of the <choose> is much clearer now, thank you. After Googling a bit I think the problem is with the column itself. It appears that the value passed to you is not a string but has some kind of object substructure. I'm not familiar with SharePoint at all (only with XSLT :-) ) but does this help you in any way: stackoverflow.com/questions/977127/… ? May 26, 2014 at 20:34

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.