I did the navi episode for CWS and I implemented it into my site. However the xslt was getting the following error
Error occured
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)
It's because the value of the passed id is not known untill runtime. When you edit the XSLT file inside Umbraco you should be able to "fix" this by checking the "skip error checking" box before you hit the save button.
If you edited the file outside of Umbraco using an external editor this error would not occur.
Thanks for the Reply Jan. IF I add the line -<a href="{umbraco.library:NiceUrl($homeNode/@id)}">- back in, I get this error "Error parsing XSLT file".
IF I remove <a href="{umbraco.library:NiceUrl($homeNode/@id)}"> and add in something along the lines of <xsl:value-of select="$homeNode/@nodeName" /> + <xsl:value-of select="$homeNode/@id" /> + <xsl:value-of select="$homeNode" /> It does not return any data. I believe the the NiceUrl Method is choking because an ID is not being passed even at runtime.
Which I am trying to understand why the xpath is not working with these two lines
As Jan asks, what's the name of your document type that Home is based on?
When you are writing your XPATH, you need to use the name of the document type, and not the node name. You could use the node name if you want to by doing somthing like this:
/*[@nodeName='Home']
Anyway, I'd suggest that you are using the document type alias, as the noge name might change some day, and then the code wouldn't work anymore.
No mater where you are in the site, you can get to the top this way - the level attribute is always called that, and if you have multiple sites in the same installation, you won't accidentally end up in another language or (God forbid!) another product catalogue :-)
Kim and Chriztian, you both rock! Kim you explained to me how the nodes work (it was homePage!! ) and Chriztian you told me a great way to make sure I am at the top for mulitple sites and the reason why my topnav was working and the left nav was not!
XSLT is not seeing the home node
I did the navi episode for CWS and I implemented it into my site. However the xslt was getting the following error
Error occured
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)
I narrowed it down to this line
<a href="{umbraco.library:NiceUrl($homeNode/@id)}">
Then I figured out that there is not any data coming back - $homeNode/@id
<!-- Root Node -->
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />
<!-- Homepage -->
<xsl:variable name="homeNode" select="$rootNode/Home [@isDoc]" />
My Root Node is "Home"
What else can I look at to see why data is not being found?
Thanks for any help
Hi Mike
It's because the value of the passed id is not known untill runtime. When you edit the XSLT file inside Umbraco you should be able to "fix" this by checking the "skip error checking" box before you hit the save button.
If you edited the file outside of Umbraco using an external editor this error would not occur.
/Jan
Thanks for the Reply Jan. IF I add the line -<a href="{umbraco.library:NiceUrl($homeNode/@id)}">- back in, I get this error "Error parsing XSLT file".
IF I remove <a href="{umbraco.library:NiceUrl($homeNode/@id)}"> and add in something along the lines of <xsl:value-of select="$homeNode/@nodeName" /> + <xsl:value-of select="$homeNode/@id" /> + <xsl:value-of select="$homeNode" /> It does not return any data. I believe the the NiceUrl Method is choking because an ID is not being passed even at runtime.
Which I am trying to understand why the xpath is not working with these two lines
<!-- Root Node -->
<xsl:variable name="rootNode" select="$currentPage/ancestor-or-self::root" />
<!-- Homepage -->
<xsl:variable name="homeNode" select="$rootNode/Home [@isDoc]" />
Hi Mike
Ah sorry, I simply just skimmed the post before. My bad.
Instead of using the root axe try doing this instead
<xsl:variable name="homeNode" select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::Home/@id)" />
<a href="{$homeNode}"/>link</a>
/Jan
No Worries Jan! However I am still getting an XSLT parsing error. It's like it cannot find "Home". The top nav xslt example however IS working
Hi Mike
What is the name of the document type of your homepage? Is it named Home? Or does it have another name? And what version of Umbraco are you using?
/Jan
Hi Mike
As Jan asks, what's the name of your document type that Home is based on?
When you are writing your XPATH, you need to use the name of the document type, and not the node name. You could use the node name if you want to by doing somthing like this:
Anyway, I'd suggest that you are using the document type alias, as the noge name might change some day, and then the code wouldn't work anymore.
/Kim A
If you want to generically select the website "root", go upwards from $currentPage until you reach level 1:
No mater where you are in the site, you can get to the top this way - the level attribute is always called that, and if you have multiple sites in the same installation, you won't accidentally end up in another language or (God forbid!) another product catalogue :-)
/Chriztian
Kim and Chriztian, you both rock! Kim you explained to me how the nodes work (it was homePage!! ) and Chriztian you told me a great way to make sure I am at the top for mulitple sites and the reason why my topnav was working and the left nav was not!
Thanks to both of you!!!
Okay, I totally get how it's supposed to work but it's still throwing an error. Below is all of the XSLT
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
]>
<xsl:stylesheet
version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:msxml="urn:schemas-microsoft-com:xslt"
xmlns:umbraco.library="urn:umbraco.library"
exclude-result-prefixes="msxml umbraco.library">
<xsl:output method="xml" omit-xml-declaration="yes"/>
<xsl:param name="currentPage"/>
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- Homepage -->
<xsl:variable name="homeNode" select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::*[@level = $level])" />
<!-- Create the link -->
<a href='{$homeNode}'>link</a>
</xsl:template>
</xsl:stylesheet>
Hi Mike
Seems like you forget the @id here.
<xsl:variable name="homeNode" select="umbraco.library:NiceUrl($currentPage/ancestor-or-self::*[@level = $level]/@id)" />
That should do it.
/Jan
is working on a reply...