<?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" xmlns:Exslt.ExsltCommon="urn:Exslt.ExsltCommon" xmlns:Exslt.ExsltDatesAndTimes="urn:Exslt.ExsltDatesAndTimes" xmlns:Exslt.ExsltMath="urn:Exslt.ExsltMath" xmlns:Exslt.ExsltRegularExpressions="urn:Exslt.ExsltRegularExpressions" xmlns:Exslt.ExsltStrings="urn:Exslt.ExsltStrings" xmlns:Exslt.ExsltSets="urn:Exslt.ExsltSets"
exclude-result-prefixes="msxml umbraco.library Exslt.ExsltCommon Exslt.ExsltDatesAndTimes Exslt.ExsltMath Exslt.ExsltRegularExpressions Exslt.ExsltStrings Exslt.ExsltSets ">
<xsl:output method="xml" omit-xml-declaration="yes" />
<xsl:param name="currentPage"/>
<xsl:variable name="MediaNodeId" select="./@id"/>
<!-- Input the documenttype you want here -->
<xsl:variable name="level" select="1"/>
<xsl:template match="/">
<!-- The fun starts here -->
<ul class=" menu nav">
<xsl:for-each select="$currentPage/ancestor-or-self::* [@level=$level]/* [@isDoc and string(umbracoNaviHide) != '1']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
<xsl:if test="count(./child::*[@isDoc and string(umbracoNaviHide) != '1']) > 0">
<ul>
<xsl:for-each select="./child::*[@isDoc and string(umbracoNaviHide) != '1']">
<li>
<xsl:choose>
<xsl:when test="name()= 'Link' ">
<xsl:if test="linkUrl!=''">
<a href="{umbraco.library:GetMedia(linkUrl, 0)/umbracoFile}" target="_blank">
<xsl:value-of select="@nodeName"/></a>
</xsl:if>
</xsl:when>
<xsl:otherwise>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/></a>
</xsl:otherwise>
</xsl:choose>
<xsl:if test="count(./child::*[@isDoc and string(umbracoNaviHide) != '2']) > 0">
<ul>
<xsl:for-each select="./child::*[@isDoc and string(umbracoNaviHide) != '2']">
<li>
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:for-each>
</ul>
</xsl:if>
</li>
</xsl:for-each>
</ul>
<div id="jflanguageselection"><div class="rawimages"><span id="active_language"><a href="http://www.hooymans-duivensport.nl/nl"><img src="/images/nl.gif" alt="Nederlands (NL-nl)" title="Nederlands (NL-nl)" /></a></span><span><a href="http://www.hooymans-duivensport.nl/en"><img src="/images/en.gif" alt="English (United Kingdom)" title="English (United Kingdom)" /></a></span></div></div>
</xsl:template>
</xsl:stylesheet>
我需要在pdf文件的菜单中建立一个链接,我收到此错误。
发生错误
System.OverflowException:对于Int32,值太大或太小。 在System.Convert.ToInt32(双值) at System.Convert.ChangeType(Object value,Type conversionType,IFormatProvider provider) 在System.Xml.Xsl.Runtime.XmlQueryRuntime.ChangeTypeXsltArgument(XmlQueryType xmlType,Object value,Type destinationType) 在System.Xml.Xsl.Runtime.XmlQueryContext.InvokeXsltLateBoundFunction(String name,String namespaceUri,IList`1 [] args) at(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug} runtime) 在Root(XmlQueryRuntime {urn:schemas-microsoft-com:xslt-debug}运行时) 在System.Xml.Xsl.XmlILCommand.Execute(Object defaultDocument,XmlResolver dataSources,XsltArgumentList argumentList,XmlWriter writer) 在System.Xml.Xsl.XslCompiledTransform.Transform(IXPathNavigable输入,XsltArgumentList参数,TextWriter结果) at umbraco.presentation.webservices.codeEditorSave.SaveXslt(String fileName,String oldName,String fileContents,Boolean ignoreDebugging)
答案 0 :(得分:1)
在XSLT解析时,此错误在Umbraco中很常见,因为解析器假定您的某些数据可能为空/空,而实际上它可能[总是]已分配。
诀窍是找到罪魁祸首的代码行并将其封装为test-for-empty-if-block。
例如,它可能是也可能不是这一行,尽管它常见于@id
和NiceUrl()
:
<xsl:otherwise>
<xsl:if test="@id != ''">
<a href="{umbraco.library:NiceUrl(@id)}">
<xsl:value-of select="@nodeName"/>
</a>
</xsl:if>
</xsl:otherwise>
错误可能来自GetMedia()
1 或NiceUrl()
2 调用,因为它们需要传递Int32类型的参数,但是我可以看到你已经在if-block中附上了GetMedia()
来电。