But it doesn't work (Error parsing XSLT file)... I've tried many variations, like "$relatedLinksCount = 0", and string comparisions instead, but nothing works...
Thanks, but that doesn't help. The thing is I can see the relatedLinksCount variable is working fine, I am outputting it and can see the value is set correctly. Its just the <xsl:if> that fails....
Oh jeez. Got it. The problem was inside my XSLT was a small bit of logic that was getting some value from some other node, and I wasn't checking this one for emptiness.
I also omitted it from my code paste above, because I thought it was inconsequential and would add noise - so you had no chance of getting it.
My bad, really sorry for wasting your time, and thanks for your help !
Really really simple Xslt test failing...
Hi,
I'm sure this is very obvious, but I can't get it to work...
XSLT - I want to test for the existence of "related content" in my xslt, but my test breaks the xslt. I'm loading my test conditioin into a variable:
<xsl:variable name="relatedLinksCount" select="count($currentPage/data[@alias='relatedLinks']/items/item)"/>
Debug Value:<xsl:value-of select="$relatedLinksCount"/>
And testing it like this:
<xsl:if test="$relatedLinksCount > 0">
But it doesn't work (Error parsing XSLT file)... I've tried many variations, like "$relatedLinksCount = 0", and string comparisions instead, but nothing works...
Can someone put me out of my misery?
Thanks!
What version of umbraco are you using?
Are you checking whether $currentPage/data[@alias='relatedLinks'] contains a value?
Hi Matt,
Post somemore of the XSLT so we can see what's going on...
/Chriztian
Hi,
Yeah, I'm checking if there are any "related links". I'm using the custom repeatible content control so the XML looks like this:
<items>
<item>
<data alias="alias1">value 1</data>
<data alias="alias2">value 2</data>
</item>
<item>
<data alias="alias1">value 3</data>
<data alias="alias2">value 4</data>
</item>
</items>
More XSLT if it helps:
<xsl:variable name="relatedLinksCount" select="count($currentPage/data[@alias='relatedLinks']/items/item)"/>
Value:<xsl:value-of select="$relatedLinksCount"/>
<xsl:for-each select="$currentPage/data[@alias='relatedLinks']/items/item">
<li>
<div class="image">
<a href="{data[@alias='relatedLinkUrl']}">
<img>
<xsl:attribute name="src">
<xsl:call-template name="ImageOrVideoThumbnail">
<xsl:with-param name="currentNode" select="umbraco.library:GetMedia(data[@alias='relatedLinkImage'],'false')"></xsl:with-param>
<xsl:with-param name="width">80</xsl:with-param>
<xsl:with-param name="height">55</xsl:with-param>
<xsl:with-param name="isMediaItem">true</xsl:with-param>
<xsl:with-param name="crop">&crop=resize</xsl:with-param>
</xsl:call-template>
</xsl:attribute>
</img>
</a>
</div>
<div class="text">
<h4>
<a href="{data[@alias='relatedLinkUrl']}">
<xsl:value-of select="data[@alias='relatedLinkText']"/>
</a>
</h4>
</div>
</li>
</xsl:for-each>
</ul>
</div>
</xsl:if>
Umbraco 4.1 btw.
Sorry that XSLT snippet was slightly incomplete, I missed out the <xslt:if> from just before the foreach that is causing it to break:
<xsl:if test="$relatedLinksCount > 0">
If I remove the test, it works, but adding it causes the xslt error.
Have you tried:
<xsl:variable name="relatedLinksCount" select="count($currentPage/data[@alias='relatedLinks']//item)"/>
Thanks, but that doesn't help. The thing is I can see the relatedLinksCount variable is working fine, I am outputting it and can see the value is set correctly. Its just the <xsl:if> that fails....
<xsl:if test="number($relatedLinksCount) > 0">?
Failing that I will bow to the XSLT wizard that is Chriztian
Oh jeez. Got it. The problem was inside my XSLT was a small bit of logic that was getting some value from some other node, and I wasn't checking this one for emptiness.
I also omitted it from my code paste above, because I thought it was inconsequential and would add noise - so you had no chance of getting it.
My bad, really sorry for wasting your time, and thanks for your help !
Matt
is working on a reply...