Date Functions

Comments

6 comments

  • Avatar
    Nathan H.

    This is not possible with XSLT 1.0 alone. You would need the help of scripts, Give me a few min.

    0
    Comment actions Permalink
  • Avatar
    Nathan H.

    try something like this.

    <!DOCTYPE xsl:stylesheet[ <!ENTITY nl "&#xd;&#xa;"> ]>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sw="http://www.interapptive.com/shipworks" extension-element-prefixes="sw" xmlns:user="urn:my-scripts" xmlns:msxsl="urn:schemas-microsoft-com:xslt">

    <xsl:import href="System\Snippets" />
    <msxsl:script language="CSharp" implements-prefix="user">
    <msxsl:assembly name="System.Web"/>
    <msxsl:using namespace="System.Web"/>
    <![CDATA[
    public DateTime GetDateValue(DateTime ODate)
    {
    DateTime od = ODate;
    return od.AddDays(2);
    }
    ]]>
    </msxsl:script>
    <xsl:output method="text" encoding="utf-8" />

    <!-- Start of template -->
    <xsl:template match="/"><xsl:apply-templates /></xsl:template>
    <xsl:template match="ShipWorks">
    <xsl:variable name="Order" select="Customer/Order" />
    <xsl:text>FullName,OrderNumber,OrderDate,ModifiedOrderDate&nl;</xsl:text>
    <xsl:for-each select="$Order">
    <xsl:value-of select="./Address[@type='ship']/FullName" /><xsl:text>,</xsl:text>
    <xsl:value-of select="./Number" /><xsl:text>,</xsl:text>
    <xsl:value-of select="./Date" /><xsl:text>,</xsl:text>
    <xsl:value-of select="user:GetDateValue(./Date)" />
    <xsl:text>&nl;</xsl:text>
    </xsl:for-each>

    </xsl:template>
    </xsl:stylesheet>
    0
    Comment actions Permalink
  • Avatar
    Nathan H.

    Let me know if you have any questions or need help with implementing this on your own template.

    0
    Comment actions Permalink
  • Avatar
    Carl Berman

    Nathan,

    In a quick review of the code you provided it appears you have given an example with the "today's date", is that correct?

    If that's so, is there a way to also do this with the "order date"?

    I will work with what you have provided in a bit and if I have any questions I will let you know.

    Thanks,

    Carl

     

    0
    Comment actions Permalink
  • Avatar
    Nathan H.

    Carl,

    That is not correct, the date that is being passed to the function in my example is the order date.

    0
    Comment actions Permalink
  • Avatar
    Carl Berman

    Ah ... ok

     

    Thanks

    0
    Comment actions Permalink

Please sign in to leave a comment.