2013-05-30 1 views
1

xslt2.0을 사용하여 1.0으로 다운 그레이드 한 다음 xalan을 사용했지만 다음 예외가 발생합니다.xslt 2.0에서 다운 그레이드 한 후 xslt1.0에서 함수를 작성하는 방법

복구 할 수있는 오류 : 줄 9 : 지원되지 않는 XSL 요소 'function'.

xslt의 부분은 다음과 같습니다. 사람이 나를 인도 할 수 순서

xslt1.0에서 :

<xsl:function name="nav:adjustDate"> 
      <xsl:param name="dateStr" /> 
      <xsl:param name="age" /> 
      <xsl:variable name="minutes"> 
        <xsl:choose> 
          <xsl:when test="$age = 1"> 
            <xsl:value-of select="0" /> 
          </xsl:when> 
          <xsl:when test="$age = 2"> 
            <xsl:value-of select="-10" /> 
          </xsl:when> 
          <xsl:when test="$age = 3"> 
            <xsl:value-of select="-20" /> 
          </xsl:when> 
          <xsl:when test="$age = 4"> 
            <xsl:value-of select="-30" /> 
          </xsl:when> 
          <xsl:when test="$age = 5"> 
            <xsl:value-of select="-40" /> 
          </xsl:when> 
          <xsl:when test="$age = 6"> 
            <xsl:value-of select="-50" /> 
          </xsl:when> 
          <xsl:otherwise> 
            <xsl:value-of select="-60" /> 
          </xsl:otherwise> 
        </xsl:choose> 
      </xsl:variable> 
      <xsl:variable name="dateFormatterStr"> 
        <xsl:text>yyyy-MM-dd'T'HH:mm:ss.SSSZ</xsl:text> 
      </xsl:variable> 
      <!-- output date format should match the input date format of the job file --> 
      <xsl:variable name="outDateFormatterStr"> 
        <xsl:text>yyyy-MM-dd'T'HH:mm:ssZ</xsl:text> 
      </xsl:variable> 
    <xsl:variable name="bo" select="bool:new('FALSE')" /> 
      <xsl:variable name="dateFormatter" select="dateFormat:new($dateFormatterStr)" /> 
      <xsl:variable name="outDateFormatter" select="dateFormat:new($outDateFormatterStr)" /> 
    <xsl:value-of select="dateFormat:setLenient($dateFormatter,$bo)" /> 
      <!-- Have to remove the colon in the timezone offset(eg. +05:00) otherwise date formatter wont work correctly --> 
      <xsl:variable name="testDate" 
        select="dateFormat:parse($dateFormatter,concat(substring($dateStr,1,string-length($dateStr)-3),'00'))" /> 
      <xsl:variable name="cal" select="gregorianCal:new()" /> 
      <xsl:value-of select="gregorianCal:setTime($cal,$testDate)" /> 
      <!-- xslt version 2 does not accept contants 12 represents the value for java.util.Calendar.MINUTE 
       Follow section of code will subtract the number of minutes--> 
      <xsl:value-of select="gregorianCal:add($cal,12,$minutes)" /> 
      <xsl:variable name="outputDate" select="gregorianCal:getTime($cal)" /> 
      <xsl:sequence select="dateFormat:format($outDateFormatter,$outputDate)" /> 
    </xsl:function> 

XSL에 대한 대체를 알고 싶어? 진행하는 방법? 은 xslt의 새로운 기능입니다.

답변

1

XSLT를 처음 사용하는 경우 스타일 시트를 XSLT 2.0에서 XSLT 1.0으로 다시 이식하는 것이 매우 어려울 수 있습니다. 행운을 빕니다.

XSLT 1.0에서는 XSLT 2.0에서 함수를 사용하는 명명 된 템플릿을 종종 사용할 수 있습니다. 외부 xsl : function 명령을 xsl : template로 변경해야합니다. 그러면 함수를 호출하는 대신 명명 된 템플릿을 호출하여 모든 호출자를 변경하여 변수를 설정해야합니다. 마지막으로 함수의 본문을 XSLT 1.0으로 변환해야합니다. 다른 사용자 선언 함수를 호출하여 초기화 된 많은 수의 변수로 판단하면 매우 느린 프로세스가됩니다.

목표 (또는이 작업을 할당 한 사람들의 목표)가 스타일 시트에 대한 길고 집중적 인 라인 별 연구의 기회를 제공하는 것이라면 이는 아마도 좋은 방법 일 것입니다. 그렇지 않으면, 내가 당신이라면, 1.0으로 다운 그레이드하는 결정을 재검토 할 것을 제안합니다.