NiceUrl failing on valid node Options
mattjk
Posted: Friday, March 07, 2008 8:22:46 AM
Rank: Devotee

Joined: 3/14/2007
Posts: 49
Hi,

Can anyone figure out why this XSLT code results in the error "System.Xml.XPath.XPathException: Function 'umbraco.library:NiceUrl()' has failed. ---> System.OverflowException: Value was either too large or too small for an Int32."?

Code:
<xsl:variable name="test" select="$currentPage/following::node[@nodeTypeAlias='Testimonial']/@id" />
<xsl:value-of select="umbraco.library:NiceUrl($test)" />


Using a simple xsl:value-of, I can see that $test is being set to 1364, which is correct (that is, it's the node ID of the node I'd expect it to return).

I've tried re-casting using number() in the value-of statement (number($test)), and in the select parameter (number($currentpage/....)) - neither help.

I've also tried dropping the xsl:variable entirely and doing the selection of the node number directly as a parameter of NiceUrl() - that doesn't work either.

Any ideas?
mattjk
Posted: Friday, March 07, 2008 8:23:57 AM
Rank: Devotee

Joined: 3/14/2007
Posts: 49
Forum broke by code Eh?

Code:
<xsl:variable name="test" select="number($currentPage/following::node[[@nodeTypeAlias='Testimonial']]/@id)" />
<xsl:value-of select="umbraco.library:NiceUrl(number($test))" />
mattjk
Posted: Friday, March 07, 2008 8:24:46 AM
Rank: Devotee

Joined: 3/14/2007
Posts: 49
And again... struggling here:

<xsl:variable name="test" select="number($currentPage/following::node(@nodeTypeAlias='Testimonial')/@id)" />
<xsl:value-of select="umbraco.library:NiceUrl(number($test))" />

( ) around @nodeTypeAlias='Testimonial' are square brackets in reality.
PeterD
Posted: Friday, March 07, 2008 10:05:09 AM

Rank: Fanatic

Joined: 7/20/2006
Posts: 486
Location: NL
Try using this:

Code:

<xsl:if test="$test != '' ">
<xsl:value-of select="umbraco.library:NiceUrl($test)" />
</xsl:if>


It did the trick for me a couple of times.

PeterD

Working on an events-calendar with recursion. Post requests on my blog!
mattjk
Posted: Saturday, March 08, 2008 1:10:21 AM
Rank: Devotee

Joined: 3/14/2007
Posts: 49
Peter Dijksterhuis wrote:

Try using this:

Code:

<xsl:if test="$test != '' ">
<xsl:value-of select="umbraco.library:NiceUrl($test)" />
</xsl:if>


It did the trick for me a couple of times.

PeterD


I don't actually have my code here to test, but are you suggesting that the XSLT parser gets it wrong when trying to save XSLTs sometimes - and throws an error like I'm seeing even though it shouldn't - but the code will work in reality?

And hence, the check you're putting around the statement using NiceUrl($test) should trick the parser into letting the XSLT be saved?
drobar
Posted: Saturday, March 08, 2008 1:51:19 AM

Rank: Umbracoholic

Joined: 9/8/2006
Posts: 1,698
Location: KY, USA
Hi, Matt,

Yes, that's more or less the idea. What happens is that umbraco compiles and tests your xslt against some of the published nodes in your site. Depending on what your xslt does, and the nodes it gets tested against, you can get runtime errors. These aren't compile errors per se, and the xslt might run just great when used properly within your site.

This situation doesn't happen all that often, but when it does, you want a way to disable the "compile and test" that happens when you save your xslt. There are two ways to do that. One is to put a checkmark in the "skip testing" box. Your xslt will be saved and you can try it in your site to see if it runs properly. But the next time you open the xslt file you'll have to remember to tick that checkbox again. To bypass that process, the xsl:if scenario is used.

Obviously, the compile and test check saves a lot of time for most error, but it isn't bullet-proof. For those situations in which you know your xslt is right, either tick the skip testing box or use the xsl:if.

cheers,
doug.

MVP 2007-2009 - Official Umbraco Trainer for North America - Percipient Studios
mattjk
Posted: Monday, March 10, 2008 8:09:42 AM
Rank: Devotee

Joined: 3/14/2007
Posts: 49
Thanks guys - Peter for the suggestion & Doug for the explanation - that solved my problem.
Users browsing this topic
Guest


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.