Hi, I tried wrapping this 'if' block around the whole anchor element and still got the same error. Is that where you meant? ie
<xsl:template match="/"> <xsl:if test="$homeId != '' "> <a class="voucher"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(umbraco.library:GetXmlNodeById($homeId)/*[@alias='giftVoucherLink'])"/> </xsl:attribute> <span>Buy a gift Voucher</span></a> </xsl:if> </xsl:template>
I'm confused about this suggested solution for 2 reasons
1) The error occurs at the point I'm trying to save the XSLT in the back-end. Surely the 'if' statement is more of a run-time check when the XSLT engine actually kicks in?
2) Why would the ID of the root node ever be empty anyway? I've got another, similar template which iterates through all the related links on the homepage based on the same ID variable and it works perfectly:
<xsl:for-each select="umbraco.library:GetXmlNodeById($homeId)/* [name() = $propertyAlias and not(@isDoc)]/links/link">
What is the requirement for the 'NiceUrl' method? Am I trying to pass the wrong type of argument in?
(Copied here, in case the old forum disappears from google forever)
"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."
You are also probably getting problems as you're mixing pre 4.5 code with 4.5 code, there is no @alias in 4.5
OK, thanks. That description from Doug helps clarify things no end, but you're right rich I was mixing my XML structure. This now works without problems:
<xsl:template match="/"> <a class="voucher"> <xsl:attribute name="href"> <xsl:value-of select="umbraco.library:NiceUrl(umbraco.library:GetXmlNodeById($homeId)/giftVoucherLink)"/> </xsl:attribute> <span>Buy a gift Voucher</span></a> </xsl:template>
It's quite difficult for those that are learning both Umbraco and XSLT together to figure out which forum posts relate to which versions of the XML schema, but at least once you'd pointed me in the right direction it was easy enough to rectify.
Fetching a URL from a content picker on a specific page
Hi,
I'm trying to render the value of a URL from a content picker on a specific page (the root / home node) via XSLT.
My XSLT looks something like this
When I try to save the XSLT file, I get the following error:
So I suspect one of my arguments is of the wrong type. Can anyone shed any light on what I'm doing wrong?
Thanks,
Matt
Hi Matt,
I think you have to insert a extra if?
<xsl:if test="$homeId != '' ">
</xsl:if>
This topic has the same solution. http://our.umbraco.org/forum/developers/xslt/3102-Using-niceurl--Value-was-either-too-large-or-too-small-for-an-Int32-
Cheers,
Bas
Hi, I tried wrapping this 'if' block around the whole anchor element and still got the same error. Is that where you meant? ie
I'm confused about this suggested solution for 2 reasons
1) The error occurs at the point I'm trying to save the XSLT in the back-end. Surely the 'if' statement is more of a run-time check when the XSLT engine actually kicks in?
2) Why would the ID of the root node ever be empty anyway? I've got another, similar template which iterates through all the related links on the homepage based on the same ID variable and it works perfectly:
What is the requirement for the 'NiceUrl' method? Am I trying to pass the wrong type of argument in?
This has been covered many, many times. (try searching Umbraco Value was either too large or too small for an Int32)
This is a great description on the error by Doug Robar here http://forum.umbraco.org/yaf_postst3143_redirect.aspx
(Copied here, in case the old forum disappears from google forever)
"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."
You are also probably getting problems as you're mixing pre 4.5 code with 4.5 code, there is no @alias in 4.5
(umbraco.library:GetXmlNodeById($homeId)/*[@alias='giftVoucherLink'])
Rich
Hi Matt,
I think you need this:
<a href="{umbraco.library:NiceUrl(umbraco.library:GetXmlNodeById($homeId)/giftVoucherLink)}">Your link name</a>
Cheers,
Bas
OK, thanks. That description from Doug helps clarify things no end, but you're right rich I was mixing my XML structure. This now works without problems:
It's quite difficult for those that are learning both Umbraco and XSLT together to figure out which forum posts relate to which versions of the XML schema, but at least once you'd pointed me in the right direction it was easy enough to rectify.
Thanks
Glad you got it sorted Matt.
I agree that it can be difficult with all the old posts, this due to before 4.5 there was no other schema, so it was never mentioned.
If you see @alias or nodeTypeAlias it's old, if you see * or name() or [isDoc] it's new
Good post here on the new and old schema http://our.umbraco.org/wiki/reference/xslt/45-xml-schema/no-more-@nodetypealias
Sounds like you're getting your head around it all, it'll be second nature soon :)
Rich
is working on a reply...