Quantcast
Channel: C1 CMS Foundation - Open Source on .NET
Viewing all articles
Browse latest Browse all 2540

New Post: DateFormatting, date is taken from MS SQL

$
0
0
Hi.
Please help solve the problem.
Get a date from the SQL, I want to put it in a more readable form.
The dates in the table contains different, but the derivation for the entire table is one and the same date. With XSLT very little sign.

Template:
<xsl:stylesheet xmlns:df = "#dateExtensions" version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:in="http://www.composite.net/ns/transformation/input/1.0" 
    xmlns:lang="http://www.composite.net/ns/localization/1.0" 
    xmlns:f="http://www.composite.net/ns/function/1.0" 
    xmlns="http://www.w3.org/1999/xhtml" 
    exclude-result-prefixes="xsl in lang f">
    <xsl:template match="/">
        <html>
            <head></head>
            <body>
                <table border="1">
                <tr align="center"><td><b>Публикация</b></td><td><b>Подписка</b></td><td><b>Ошибок</b></td><td><b>Последняя успешная</b></td></tr>
                <xsl:apply-templates select="/in:inputs/in:result[@name='ReportBadReplication']/root/NewDataSet/Table"/>
                </table>
            </body>
        </html>
    </xsl:template>
    <xsl:template match="/in:inputs/in:result[@name='ReportBadReplication']/root/NewDataSet/Table">
    <tr>
      <td width="230"><xsl:value-of select="NamePub"/></td>
      <td width="160"><xsl:value-of select="NameSub"/></td>
      <td width="80" align="center"><xsl:value-of select="ReplBad"/></td>
      <td><xsl:value-of select="df:ShortDateFormat(/in:inputs/in:result[@name='ReportBadReplication']/root/NewDataSet/Table/ReplDateGood)"/>&#160;<xsl:value-of select="df:ShortTimeFormat(/in:inputs/in:result[@name='ReportBadReplication']/root/NewDataSet/Table/ReplDateGood)"/></td>
    </tr>
  </xsl:template>

</xsl:stylesheet>
Input:
<in:inputs xmlns:in="http://www.composite.net/ns/transformation/input/1.0">
    <!-- Function call result 'DateFormatting' has been registered as an Xslt Entension Object. -->
    <!-- Extension methods can be called using the namespace '#dateExtensions'. -->
    <!-- The following methods exist: -->
    <!-- String ns:Now() -->
    <!-- String ns:LongDateFormat(String xmlFormattedDate) -->
    <!-- String ns:LongTimeFormat(String xmlFormattedDate) -->
    <!-- String ns:ShortDateFormat(String xmlFormattedDate) -->
    <!-- String ns:ShortTimeFormat(String xmlFormattedDate) -->
    <!-- Int32 ns:Day(String xmlFormattedDate) -->
    <!-- Int32 ns:Month(String xmlFormattedDate) -->
    <!-- Int32 ns:Year(String xmlFormattedDate) -->
    <!-- String ns:LongMonthName(Int32 monthNumber) -->
    <!-- String ns:ShortMonthName(Int32 monthNumber) -->
    <!-- String ns:Format(String xmlFormattedDate, String DateFormat) -->
    <!-- Function Call Result (5 ms), XPath /in:inputs/in:result[@name='ReportBadReplication']/root  -->
     <in:result name="ReportBadReplication">
         <root xmlns="">
             <NewDataSet>
                 <Table>
                    <ID>8552</ID>
                    <Client>SoftService</Client>
                    <NamePub>RedCup_pub</NamePub>
                    <NameSub>pos3</NameSub>
                    <ReplGood>0</ReplGood>
                    <ReplBad>156</ReplBad>
                    <ReplDateGood>2014-08-31T21:56:00+04:00</ReplDateGood>
                    <ReplDateBad>2014-09-05T12:52:00+04:00</ReplDateBad>
                </Table>
                 <Table>
                    <ID>8661</ID>
                    <Client>SoftService</Client>
                    <NamePub>RedCup_pub</NamePub>
                    <NameSub>unit164</NameSub>
                    <ReplGood>0</ReplGood>
                    <ReplBad>156</ReplBad>
                    <ReplDateGood>2014-09-04T14:01:00+04:00</ReplDateGood>
                    <ReplDateBad>2014-09-05T12:52:00+04:00</ReplDateBad>
                </Table>
            </NewDataSet>
        </root>
    </in:result>
</in:inputs>
Result:
<html xmlns="http://www.w3.org/1999/xhtml">
    <head/>
     <body>
         <table border="1">
             <tr align="center">
                 <td>
                    <b>Публикация</b>
                </td>
                 <td>
                    <b>Подписка</b>
                </td>
                 <td>
                    <b>Ошибок</b>
                </td>
                 <td>
                    <b>Последняя успешная</b>
                </td>
            </tr>
             <tr>
                <td width="230">RedCup_pub</td>
                <td width="160">pos3</td>
                <td width="80" align="center">156</td>
                <td>31.08.2014 21:56</td>
            </tr>
             <tr>
                <td width="230">RedCup_pub</td>
                <td width="160">unit164</td>
                <td width="80" align="center">156</td>
                <td>31.08.2014 21:56</td>
            </tr>
        </table>
    </body>
</html>
I know that's not right, something pointed out, but I do not know that for sure.
Thanks in advance for your help.

Viewing all articles
Browse latest Browse all 2540

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>