2013-05-29 2 views
0

포럼에서 GetMedia로 오류를 검색하면 함수에 제공하는 변수가 정수가 아님을 알 수 있습니다.umbraco xslt getMedia 오류

다음은 오류입니다. System.OverflowException : 값이 Int32에 비해 너무 크거나 작습니다.

<xsl:value-of select="$currentPage/image" /> 

출력했다 :

1663 

다음 내가 이것을 시도 : 그것은 나에게 내가 위에서 당신을 쓴 오류를 반환

<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/image, false())" /> 

나는 나의 변수를 확인합니다. $ currentPage/image 대신에 1663을 썼다면 작동하지만, 하드 코드 된 것이므로 하드 코딩되지 않을 것입니다.

여기 내 XSLT

<xsl:template match="/"> 

<!-- start writing XSLT --> 
<xsl:value-of select="$currentPage/image" /> 
<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/image, false())" /> 
<div class="tfirst"> 
<p> 
    <!--xsl:if test="not($media/error)"> 
     <img src="{$media/umbracoFile}" class="left timg" /> 
    </xsl:if--> 
    <div class="ttext"> 
     <h2><xsl:value-of select="umbraco.library:StripHtml($currentPage/title)" /></h2> 
     <xsl:value-of select="$currentPage/abstractText" disable-output-escaping="yes" /> 
    </div> 
</p> 
</div> 
<div class="ttext"> 
<xsl:if test="$currentPage/showMultipleColumns='1'"> 
    <xsl:attribute name="class">showMultipleColumns</xsl:attribute> 
</xsl:if> 
<xsl:value-of select="$currentPage/bodyText" disable-output-escaping="yes" /> 
</div> 

</xsl:template> 

는 당신의 도움을 주셔서 감사합니다. 벤자민

편집 ------------------

나는 시험 경우를 추가하려고했지만 내가 $ currentPage를 교체 할 경우 지금은 나에게 또 다른 오류를 줄/image by 1663 : System.Xml.Xsl.XslTransformException : 경로 식에서 결과 트리 단편을 사용하려면 먼저 msxsl : node-set() 함수를 사용하여 노드 집합으로 변환합니다.

내가 항상 가지고있는 $ currentPage/image를 보겠습니다. System.OverflowException : 값이 Int32에 비해 너무 크거나 작습니다.

<xsl:variable name="atest" select="umbraco.library:GetMedia($currentPage/image, false())" /> 
<xsl:variable name="media"> 
    <xsl:if test="$currentPage/image &gt; 0"> 
     <xsl:value-of select="$atest" /> 
    </xsl:if> 
</xsl:variable> 

Edit2가 ------------

항상 오류가 점점 아래이 시도 : System.OverflowException이를 : 여기에

는 XSLT이다 값이 너무 큰 중 하나였다 Int32에서는 너무 작습니다.

<xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/image, false())" /> 
<xsl:if test="$media"> 
    <img src="{$media/umbracoFile}" class="left timg" /> 
</xsl:if> 

답변

0

umbraco.Library : GetMedia() 함수를 호출하기 전에 $ currentPage/image가> 0인지 확인해야합니다. 왜 그런지 기억할 수는 없지만 몇 년 전에 같은 문제가 발생했습니다. 제대로 리콜하면 이유가있었습니다.

이 시도 :

<xsl:variable name="mediaId" select="$currentPage/image)" />  
<xsl:if test="$mediaId > 0"> 
    <xsl:variable name="media" select="umbraco.library:GetMedia($mediaId, 0)" /> 
</xsl:if> 

편집 :

당신이 가진 Umbraco 매크로 편집기에 추가하는 데 필요한 검사와 혼란 스러워요. 이미지 렌더링은 다음과 같이 간단해야합니다.

+0

안녕하세요, 지금 시도해 보았습니다. System.Xml.Xsl.XslTransformException : 결과 트리 조각을 경로 식에 사용하려면 먼저 msxsl : node- set() 함수. 자세한 내용은 내 게시물의 편집 부분을 참조하십시오. – Benjamin

+0

테스트가 잘못되어 테스트에서 줄의 순서가 바뀌 었습니다. 제 예제의 정확한 순서대로 시도하십시오. –

+0

예제를 시도했지만 항상 int32에 대한이 오류가 발생했습니다. 내 편집 2보기 – Benjamin

0

도움 주셔서 감사합니다. 내 문제 해결 방법을 찾았습니다. 내 이미지가 필수 항목이 아니기 때문에 (예 : 이전에 알려야 할 사항). 방금 ​​했어요 :

<xsl:if test="$currentPage/image &gt; 0"> 
    <xsl:variable name="media" select="umbraco.library:GetMedia($currentPage/image, false())" /> 
    <xsl:if test="not($media/error)"> 
    <img src="{$media/umbracoFile}" class="left timg" /> 
    </xsl:if> 
</xsl:if> 

이제 제대로 작동합니다. 도움 주셔서 감사합니다. 멋진 하루 보내십시오. Benjamin

관련 문제