System.OverflowException: Value was either too large or too small for an
Int32.
at System.Convert.ToInt32(Double value)
at System.Convert.ChangeType(Object value, Type conversionType,
IFormatProvider provider)
at
System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType
xmlType, Object value, Type destinationType)
at
System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String
name, String namespaceUri, IList`1[] args)
at (XmlQueryRuntime
{urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime
{urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,
XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter
writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable
input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String
fileName, String oldName, String fileContents, Boolean ignoreDebugging)
Before making the call to GetMedia, you should check if the value is not empty.
<xsl:if select="sportsSmallIcons != '' ">
When saving the xslt, umbraco tries to validate it against the root node. If that node does not have a property sportsSmallIcons, then GetMedia will fail because it does not get an integer passed.
When I added the if statement, the file saved without any problems, but no images were shown on the website. Changing the statement to include $currentPage solved this and it is now all up and running.
Thanks for the explanation as to why the error, this makes everything much clearer.
Peter I would vote your answer as corrent, but I do not have enough Karma points yet.
I have to just mention that the 'hidden' entity you've declared is not going to do what you think it does (it returns true whether umbracoNaviHide is 0 or 1). You should do something like this instead:
<!ENTITY hidden "*[@isDoc and umbracoNaviHide = 1]">
Just so you don't copy&paste this one from file to file and it suddenly bites you... :-)
First, lets get rid of all the duplication and use a simple pattern: Provide a single template for the Document Type, and in the root (/) template you select the Documents you want to output - the last template handles the hidden nodes:
Now, I don't know the exact structure of your site, but the way you had set up for the hidden nodes, your template was only set to match documents that had a hidden child page - not documents that were hidden themselves, and I don't know if that was intentional, but I'm guessing not.
Another thing: Is your umbracoNaviHide property defined as a "Boolean (True/False)" property? (This should give 1 and 0 as values).
Actually, the pipe is kind of a join operator - it joins the node sets returned from the expressions on the sides, so it takes both the homePage (left side) and its children (right side) and collects them all in one set, which it then applies templates to.
xsl:attribute adds an attribute to the element that is currently being generated and it has to be put before you generate content inside the element, e.g.:
<!-- This works: -->
<a>
<xsl:attribute name="class">selected</xsl:attribute>
Click Me!
</a>
<!-- This does not work: -->
<a>
Click Me!
<xsl:attribute name="class">selected</xsl:attribute>
</a>
4.5 Images Int32 error
I am trying to display images in 4.5 using the following code.
This has worked for me when in a for-each loop, but is not now.
Have checked all the images are there and correct as far as I can tell.
Thanks.
Might be some typing mistakes...
should be
and what's your
sportsIconImageLeft
variable, seems not be declared in the code?
Also, check out Lee's article on using GetMedia() (altho still uses the old pre 4.5 syntax)
Hope this helps.
Regards,
/Dirk
Dirk, thank you for your reply.
The sportsIconImageLeft is a media picker in the Document Type for the page.
Have made the changes you suggested without luck.
Have used this technique on other pages, but always with other code around (see below), which works.
Should I re-create the Document Type property?
Have just had the same thing happen with another version of the same code.
The exact error I am seeing (on save) is:
System.OverflowException: Value was either too large or too small for an Int32.
at System.Convert.ToInt32(Double value)
at System.Convert.ChangeType(Object value, Type conversionType, IFormatProvider provider)
at System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType, Object value, Type destinationType)
at System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name, String namespaceUri, IList`1[] args)
at (XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}runtime)
at System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument, XmlResolver dataSources, XsltArgumentList argumentList, XmlWriter writer)
at System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable input, XsltArgumentList arguments, TextWriter results)
at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName, String oldName, String fileContents, Boolean ignoreDebugging)
If this is ignored the code works!
The code I am using has change to the following:
Why the error, but works on the page?
Before making the call to GetMedia, you should check if the value is not empty.
<xsl:if select="sportsSmallIcons != '' ">
When saving the xslt, umbraco tries to validate it against the root node. If that node does not have a property sportsSmallIcons, then GetMedia will fail because it does not get an integer passed.
HTH,
Peter
Peter, many thanks.
When I added the if statement, the file saved without any problems, but no images were shown on the website. Changing the statement to include $currentPage solved this and it is now all up and running.
Thanks for the explanation as to why the error, this makes everything much clearer.
Peter I would vote your answer as corrent, but I do not have enough Karma points yet.
My final code is:
Hi TaoistTotty,
I have to just mention that the 'hidden' entity you've declared is not going to do what you think it does (it returns true whether umbracoNaviHide is 0 or 1). You should do something like this instead:
Just so you don't copy&paste this one from file to file and it suddenly bites you... :-)
/Chriztian
Chriztian
Thank you very much for this.
Is there a good book etc. on all of this.
TT
Chriztian
Have tried the hidden you suggested and this did not work (the full code is below), but the one I had does.
Do you know why - this has worried me as I know your know your XSLT.
Any advice gratefully received.
Hi TT,
First, lets get rid of all the duplication and use a simple pattern: Provide a single template for the Document Type, and in the root (/) template you select the Documents you want to output - the last template handles the hidden nodes:
Now, I don't know the exact structure of your site, but the way you had set up for the hidden nodes, your template was only set to match documents that had a hidden child page - not documents that were hidden themselves, and I don't know if that was intentional, but I'm guessing not.
Another thing: Is your umbracoNaviHide property defined as a "Boolean (True/False)" property? (This should give 1 and 0 as values).
/Chriztian
Hi Chriztian
Thanks for this, I am just getting my head around this - I am also looking at the article you have produced on you website.
I assume the | means try either one.
Had a problem initially, but looking at the code with a clear head helped (leaving selected in the link will always cause a problem).
Does the xsl:attribute alway alter the preceeding HTML?
Thanks for all the help.
TT
Hi TT,
Actually, the pipe is kind of a join operator - it joins the node sets returned from the expressions on the sides, so it takes both the homePage (left side) and its children (right side) and collects them all in one set, which it then applies templates to.
xsl:attribute adds an attribute to the element that is currently being generated and it has to be put before you generate content inside the element, e.g.:
/Chriztian
Chriztain
Thanks ever so much, this now makes sense.
Once again thank you for all your help.
Regards
TT
is working on a reply...