在XSL中将格式化日期转换为字符串

时间:2017-10-03 06:53:00

标签: xml xslt xslt-1.0 xslt-2.0

我正在尝试将日期格式yyyy-MM-dd从XML转换为yyyy / MM / dd

<requestMessage>
<custRefNo>123456789876</custRefNo>
<printDate>2017-09-09</printDate>
<dbName>default</dbName>
<filename>abcedfed</filename>
<filePointer>ABCDEFGHIJKL</filePointer>
<format>afp</format>
</requestMessage>

使用XSL tranfomration

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
 <xsl:output method="xml" omit-xml-declaration="yes" indent="yes"/>

 <xsl:template match="/requestMessage">
  <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ws="http://ouaf.oracle.com/">
     <soapenv:Header/>

     <soapenv:Body>
        <ws:documentInfo>
            <ws:dbname>
              <xsl:value-of select="dbName"/>
           </ws:dbname>
           <ws:account>
              <xsl:value-of select="custRefNo"/>
           </ws:account>
           <ws:date>
              <xsl:value-of select="format-date(printDate,'[Y0001]/[M01]/[D01]')"/>
           </ws:date>
           <ws:format>
              <xsl:value-of select="format"/>
           </ws:format>
           <ws:file>
              <xsl:value-of select="filename"/>
           </ws:file>
           <ws:pointer>
              <xsl:value-of select="filePointer"/>
           </ws:pointer>

        </ws:documentInfo>
     </soapenv:Body>
  </soapenv:Envelope>
 </xsl:template>
</xsl:stylesheet>

获取XML

        <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                          xmlns:ws="http://ouaf.oracle.com/">
           <soapenv:Header/>
           <soapenv:Body>
              <ws:documentInfo>
                 <ws:dbname>default</ws:dbname>
                 <ws:account>123456789876</ws:account>
                 <ws:date>2017/09/09</ws:date>
                 <ws:format>afp</ws:format>
                 <ws:file>abcedfed</ws:file>
                 <ws:pointer>ABCDEFGHIJKL</ws:pointer>
              </ws:documentInfo>
           </soapenv:Body>
        </soapenv:Envelope>

但我认为我的XSL正在将节点从字符串更改为日期格式。由于它我的Web服务失败。任何人都可以建议如何使用我的XSL再次在字符串中转换格式化的日期。

0 个答案:

没有答案
相关问题