2012-05-31 2 views
-2

format-dateTime() 함수 안에서 날짜 계산을하고 XSL 변환을하고 싶습니다. 여기 내 XSL 파일이 코드는 오류 가 발생XSLT : 함수 안에서 날짜 계산하기 [format-dateTime()]

<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ns="http://www.abc.com/ws/integration/toolkit/2005/07" xmlns:fct="http://www.taleo.com/xsl_functions" xmlns:xs="http://www.w3.org/2001/XMLSchema"> 
<xsl:output method="xml" encoding="UTF-8"/> 
<xsl:template match="/"> 
    <xsl:apply-templates/> 
</xsl:template> 
<xsl:template match="@*|node()"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*|node()"/> 
    </xsl:copy> 
</xsl:template> 
<xsl:template match="ns:field[@name = 'EndDate']"> 
    <xsl:copy> 
     <xsl:apply-templates select="@*"/> 
     <xsl:value-of select="fct:format-considering-timezone(xs:dateTime(.))"/> 
    </xsl:copy> 
</xsl:template> 
<xsl:function name="fct:format-considering-timezone"> 
    <xsl:param name="dateTime" as="xs:dateTime"/> 
    <xsl:variable name="dst"> 
     <xsl:value-of select="fct:get-timezone($dateTime)"/> 
    </xsl:variable> 
    <xsl:variable name="date-format"> 
     <xsl:choose> 
      <xsl:when test="$dst = 'PT11H'">[Y,4-4]-[M,2-2]-[D,2-2]02:00:00T-05:00</xsl:when> 
      <xsl:otherwise>[Y,4-4]-[M,2-2]-[D,2-2]00:00:00T-05:00</xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable>    
    <xsl:variable name="Duration"> 
     <xsl:choose> 
      <xsl:when test="ns:field[@name='CareerSiteNo3'] = 'xyz'">P2D</xsl:when> 
      <xsl:otherwise>P14D</xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <xsl:variable name="AUTime"> 
     <xsl:value-of select="adjust-dateTime-to-timezone($dateTime + xs:dayTimeDuration($Duration), $dst)"/> 
    </xsl:variable> 
    <xsl:value-of select="format-dateTime((xs:datetime($AUTime) + xs:dayTimeDuration($Duration)), $date-format)"/> 
</xsl:function> 
<xsl:function name="fct:get-timezone" as="xs:dayTimeDuration"> 
    <xsl:param name="dateTime" as="xs:dateTime"/> 
    <xsl:variable name="timezone"> 
     <xsl:choose> 
      <xsl:when test="$dateTime gt xs:dateTime('2030-10-06T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2030-04-07T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2029-10-07T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2029-04-01T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2028-10-01T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2028-04-02T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2027-10-03T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2027-04-04T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2026-10-04T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2026-04-05T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2025-10-05T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2025-04-06T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2024-10-06T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2024-04-07T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2023-10-01T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2023-04-02T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2022-10-02T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2022-04-03T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2021-10-03T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2021-04-04T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2020-10-04T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2020-04-05T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2019-10-06T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2019-04-07T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2018-10-07T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2018-04-01T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2017-10-01T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2017-04-02T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2016-10-02T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2016-04-03T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2015-10-04T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2015-04-05T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2014-10-05T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2014-04-06T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2013-10-06T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2013-04-07T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2012-10-07T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2012-04-01T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2011-10-02T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2011-04-03T03:00:00+10:00')">PT10H</xsl:when> 
      <xsl:when test="$dateTime gt xs:dateTime('2010-10-03T02:00:00+11:00')">PT11H</xsl:when> 
      <xsl:otherwise> 
       <xsl:value-of select="concat(' Error - dateTime : ', $dateTime, ' out of range. Need to extend the list of DST datetimes.')"/> 
      </xsl:otherwise> 
     </xsl:choose> 
    </xsl:variable> 
    <xsl:value-of select="xs:dayTimeDuration($timezone)"/> 
</xsl:function> 

이다. "는, TransformerConfigurationException을 :. 스타일 시트를 컴파일하는 데 실패 감지 한 오류". I 데이터의 계산을 포함하지 않는 본 <xsl:value-of select="format-dateTime($AUTime, $date-format)"/>, 같은 부분을 <xsl:value-of select="format-dateTime((xs:datetime($AUTime) + xs:dayTimeDuration($Duration)), $date-format)"/> 변경

<?xml version="1.0" encoding="UTF-8"?> 
<Envelope xmlns="http://schemas.xmlsoap.org/soap/envelope/" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> 
<Body> 
    <getDocumentByKeyResponse xmlns="http://www.abc.com/ws/integration/toolkit/2005/07" xmlns:ns1="http://www.abc.com/ws/integration/toolkit/2005/07" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"> 
     <Document> 
      <Attributes> 
       <Attribute name="duration">0:00:00.086</Attribute> 
       <Attribute name="count">2</Attribute> 
       <Attribute name="entity">SourcingRequest</Attribute> 
       <Attribute name="mode">XML</Attribute> 
       <Attribute name="version">http://www.taleo.com/ws/tee800/2009/01</Attribute> 
      </Attributes> 
      <Content> 
       <ExportXML> 
        <record> 
         <field name="Identifier">00000abc</field> 
         <field name="ContestNumber">00000abc</field> 
         <field name="CareerSiteNo3">xyz</field> 
         <field name="OpeningDate">2012-02-15</field> 
         <field name="EndDate">2012-02-1602:00:00T-05:00</field> 
        </record> 
      </Content> 
     </Document> 
    </getDocumentByKeyResponse> 
</Body> 

가 변환 프로세스가 성공 : 여기

는 I 변환하고자하고 출력한다.

format-dateTime()> 안에 계산을 수행 할 수 없습니까? 당신이 그것을에 예상대로

많은 감사

답변