如何修复日期格式?

时间:2015-11-02 21:21:30

标签: xml xslt

我想修复我的xslt以便我的

<Integration xmlns:msxsl="urn:schemas-microsoft-com:xslt" xmlns:tsg="http://tsgweb.com" xmlns:IXML="http://tsgweb.com" xmlns:CMCodeQueryHelper="urn:CMCodeQueryHelper" PackageID="ChargeDispSent" MessageID="670"> <Case InternalID="16170" ID="12" xmlns:user="http://tylertechnologies.com"> <SentenceEvent ID="1606"> <Sentence ID="776"> <SentenceCharge> <ChargeID InternalChargeID="1616">1091</ChargeID> </SentenceCharge> <Additional> <HomeMonitoringComponent> <Duration Op="E"> <StartDate>11/03/2015</StartDate> <EndDate>12/02/2015</EndDate> <StartTime Op="E">8:00 AM</StartTime> <EndTime Op="E">9:00 AM</EndTime> </Duration> </HomeMonitoringComponent> </Additional> </Sentence> </SentenceEvent> </Case>

看起来不像这样。我希望有日期和时间。

我的xml文档

<xsl:if test="string-length(Duration/StartDate) &gt; 0">
        <xsl:for-each select="Duration">
            <DispositionDurationalElement>
                <StartDateTime>
                    <xsl:value-of select="mscef:formatDateTime(string(concat(Duration/StartDate, ':', Duration/StartTime)))"/>
                </StartDateTime>
                <xsl:if test="string-length(Duration/EndDate)!=0">
                    <EndDateTime>
                        <xsl:value-of select="mscef:formatDateTime(string(concat(Duration/EndDate, ':', Duration/EndTime)))"/>
                    </EndDateTime>
                </xsl:if>
            </DispositionDurationalElement>
            </xsl:for-each>
        </xsl:if>

格式化并显示日期的我的xslt看起来像这样

<DispositionDurationalElement>
                <StartDateTime>NaN-NaN-NaNTNaN:NaN:NaN-NaN:00</StartDateTime>
            </DispositionDurationalElement>

我的输出看起来像这样

{ 'number' : tags[i] },

1 个答案:

答案 0 :(得分:0)

  

另一方面,我想知道如何才能显示未格式化的日期和   时间相反?像这样<StartDateTime>11/03/2015: 8:00 AM</StartDateTime>

这很容易 - 只需使用:

<StartDateTime>
    <xsl:value-of select="concat(StartDate, ': ', StartTime)"/>
</StartDateTime>