XML Editor
Sign up for a WebBoard account Sign Up Keyword Search Search More Options... Options
Chat Rooms Chat Help Help News News Log in to WebBoard Log in Not Logged in
Conferences Close Tree View
+ Stylus Studio Feature Requests (1192)
+ Stylus Studio Technical Forum (14621)
+ Website Feedback (249)
- XSLT Help and Discussion (7625)
-> + Flatten an XML source (2)
-> + Problem in navigating tree (2)
-> + preserve line breaks in xml at... (4)
-> + XSLT to PDF (2)
-> + Replace a nodeset with another... (3)
-> + Nested variable compile error ... (5)
-> + Replace a nodeset with another... (2)
-> + StackOverFlow Error, while com... (4)
-> + Footnote - WORDML (6)
-> + Concatenate same input element... (3)
-> + Need to remove the sub element... (3)
-> + Grabbing sub-namespace values (2)
-> + Converting date via browser XS... (4)
-> + Selecting Attribute nodes (2)
-> + XSLT totaling numeric values (4)
-> + Two line output by breaking on... (3)
-> + Encoding Option for base64Bina... (2)
-> + using document and web service... (2)
-> + XSLT transformations with JDK1... (8)
-> - Parsing Excel XML - Selectiing... (1)
-> + Grouping this xml input very n... (2)
-> + XSL-FO page-sequence and blank... (2)
-> + Need Help In XSLT Mapping (3)
-> + how to create the Tables by co... (2)
-> + fo:external-graphic - Image ... (2)
-> + Mapping complex document with ... (8)
-> + Sorting in XSLT (2)
-> - xsl date time adding... (16)
-> ->xsl date time adding...
-> ->xsl date time adding...
-> ->xsl date time adding...
-> ->xsl date time adding...
-> ->xsl date time adding...
-> ->xsl date time adding...
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> ->Re: xsl date time adding....
-> - Flat XML to nested XML convers... (1)
-> + parser for parsing XSL file (2)
-> - q on group function (1)
-> + compare 2 date value using xsl (2)
-> - Remove namespaces from SOAP pa... (1)
-> + Numeric string not displaying ... (3)
-> + where is the old HTM to XSL wi... (2)
-> + XSLT variable path (2)
-> + Sort by lookup values & styles... (2)
-> + Hi without hard code filed na... (2)
-> + XSLT output does not work (2)
-> + How can I do this javascript i... (2)
-> + Paging with XSL and passing UR... (2)
-> + XPath Condition Query (3)
-> + Xalan Multiple XML Output Over... (3)
-> + Inserting Line Break (2)
-> + Get Value from non-standard xm... (2)
-> + Root node renaming and adding ... (2)
-> + Cannot get CDATA to render pro... (2)
-> - How to add a footer on reports... (1)
-> - Apply-templates and processing... (1)
-> + Help Please - Use data from no... (5)
-> - Behaviour of trace function (1)
-> + How to Build a Dynamic XPath E... (3)
-> - raw xml to generic xml (1)
-> - Merging two documents (1)
-> + XSLT Path help (3)
-> + how to sort, dates in xsl ? (3)
-> + Naming elements (3)
-> + XSL IF Statement (2)
-> + XSLT Help Needed (4)
-> + Character Increment (4)
-> - concat function not working wi... (1)
-> + XSLT only namespace attribute ... (2)
-> - using uri within RSS enclosure... (1)
-> + Transforming Data With XSLT (3)
-> + Validate XPath on variable (8)
-> - flatten xml structure then sor... (1)
-> + SYNTAX not working (2)
-> + Looping through xml document (3)
-> + can i modify the xml data in X... (2)
-> + can i modify the xml data in X... (2)
-> + regex (2)
-> + xslt document and web services... (2)
-> + looping question (2)
-> + XML to Excel Conversion using ... (4)
-> + Compare (2)
-> + problem in loadxml function (2)
-> + does IE support script in xsl (2)
-> + converting Time format (2)
-> + Single Message split into Mult... (5)
-> + xml template design (2)
-> + String to array (2)
-> + Page Break with XSL-FO (4)
-> + Need help Translating string (2)
-> + Transforming input xml paramet... (3)
-> + How to transform node from inc... (2)
-> + XSL:FO Marker Question (2)
-> + trim after character...? (2)
-> + Convernting CSS + xsl to XSL:F... (2)
-> + save external image in xml/xsl (3)
-> + Table of Contents (2)
-> + Problem with select expression (2)
-> + Slow for-each select (7)
-> + Restructuring XML (2)
-> + Coloring xml output (3)
-> + Looping through xsl based on a... (5)
-> + Where is the wizard? (3)
-> + Save XML thru href (2)
-> + existing xslt, source and dest... (5)
-> + spliting xml files by certain ... (8)
-> + checking condition and writing... (2)
-- Previous [481-500] [501-520] [521-540] Next
+ XQuery Help and Discussion (2017)
+ Stylus Studio FAQs (159)
+ Stylus Studio Code Samples & Utilities (364)
+ Stylus Studio Announcements (113)
Topic  
Postnext
tyler horathSubject: xsl date time adding...
Author: tyler horath
Date: 08 Oct 2008 02:20 PM
Ok so here is my situation. I am generating a wordpress (blog) import file from an xml file using xslt. I am trying to add an hour to each publish date node. So for example....

<title> Post 1 </title>
<pubdate>8-10-2008 5:00</pubdate> ( I realize the format may not be right)

<title> Post 2</title>
<pubdate>8-10-2009 6:00</pubdate>

You get the idea. This way I can import thousands of post and wordpress will automatically post them when their time comes up in the future. I have tried using the exslt date:add string with no luck.

Any ideas on how I can do this?

Postnext
tyler horathSubject: xsl date time adding...
Author: tyler horath
Date: 09 Oct 2008 02:39 PM
any ideas?

Postnext
Minollo I.Subject: xsl date time adding...
Author: Minollo I.
Date: 09 Oct 2008 02:51 PM
Using XSLT 2.0 (or Saxon 9.x, which understands some XSLT 2.0 concepts even when using XSLT 1.0), you can do:
xs:dateTime('2008-10-08T05:00:00')+xs:dayTimeDuration('PT1H')

You will need to format your date in the correct format to make xs:dateTime() digest it.

Postnext
tyler horathSubject: xsl date time adding...
Author: tyler horath
Date: 09 Oct 2008 03:36 PM
I am using xmlspy and when I try to debug it closes xmlspy.

Postnext
Minollo I.Subject: xsl date time adding...
Author: Minollo I.
Date: 09 Oct 2008 03:43 PM
...which seems to suggest you are either using the wrong tool or the wrong discussion forum.

Postnext
tyler horathSubject: xsl date time adding...
Author: tyler horath
Date: 09 Oct 2008 03:48 PM
ok I got it working, but when its inside my for each loop it just adds to hour to all of the nodes. I want it to add an hour to each from the current hour of the last node. so its 1:00 then 2:00 then 3:00 then 4:00, etc.

Postnext
tyler horathSubject: xsl date time adding...
Author: tyler horath
Date: 12 Oct 2008 04:07 PM
is there a way to do some sort of recursion with the datE to add it to the last?

like i = i + 1

Postnext
(Deleted User) Subject: Re: xsl date time adding...
Author: (Deleted User)
Date: 13 Oct 2008 06:10 AM
do you have a specific objective on why you wanted to do some sort of
recursion?.... So for me to know how may i help you.

On 10/13/08, stylus-studio-xslt Listmanager <
stylus-studio-xslt.listmanager@stylusstudio.com> wrote:
>
> From: tyler horath
>
> is there a way to do some sort of recursion with the datE to add it to the
> last?
>
> like i = i + 1
>
>
>
> --
> To reply:stylus-studio-xslt.25314@stylusstudio.com
> To start a new topic:stylus-studio-xslt@stylusstudio.com
> To login:http://www.stylusstudio.com/SSDN/
> To (un)subscribe:stylus-studio-xslt.list-request@stylusstudio.com
>



--
"We can observe and theorize. But we can never know how. Reality is
something we can only approach"-albert enstein

Postnext
tyler horathSubject: Re: xsl date time adding...
Author: tyler horath
Date: 13 Oct 2008 09:05 AM
anyway that will work is fine by me. I just want the date to start at the current time on the first node, then to keep adding an hour to each node.

<example>
<item>
<pubdate>10-13-2008 8:00</pubdate>
</item>
<item>
<pubdate>10-13-2008 9:00</pubdate>
</item>
<item>
<pubdate>10-13-2008 10:00</pubdate>
</item>
<item>
<pubdate>10-13-2008 11:00</pubdate>
</item>
<item>
<pubdate>10-13-2008 12:00</pubdate>
</item>
<item>
<pubdate>10-14-2008 1:00</pubdate>
</item>
</example>

and so on...

And in doing this hopefully the days will change as the hours pass 24 or whatever.

Postnext
(Deleted User) Subject: Re: xsl date time adding...
Author: (Deleted User)
Date: 13 Oct 2008 11:03 PM
oh i see, I'm still a newbie at this. But i got the same problem before
when I was tasked to convert the current time to the time based on GMT, so
with that , i had to add 8 hours each time i pull and transform the xml
date node required to be converted.
Take note that in xslt version 2, we can already use functions for
datetime manipulations etc , also, we can already use some datetime
functions like dateadd etc..
But in xslt version 1, we are ony limited in using templates, this was my
problem before becuase i was only limited to code using xslt version 1.
What i did was , I created my own set of templates that will be called
while I transform the date node. These templates will :
1. Select the current datetime node and converts it to a date-time format
that can be easily divided into :
a. Date, Time and Year
2. Get the time,day,month and year
(DoAddHour,DoAddDate,DoAddMonth,DoAddYear)
3. Pass the formatted current date as a variable to the DoAddTime, this
template should basically :
a.get the time in HH:mm:ss tt,
b. add 8 hours as per GMT requirement
c. Compare the resulting Time if this excedds 24 hours
d. if exceeds to 24 hours, call template DoAddDate

* .... do this until the DoAddYear template .... see the sample
templates below*
.. You can use a set of ms:format-date, ms:format-time, substring
-available functions in xslt version 1
the DoAddHour,DoaddDate, DoAddMonth, DoaddYear will depend on how it will be
used, as for me since I was tasked to display the output as, Monday, Feb
28, 2008, the template for DoAddHour,DoAddDate,DoAddMonth simply contained
a set of xsl:choose, xsl:when for days :Monday, Tuesday wednesday etc.. and
months: Jan, February, March , April.
ex..
* ** <xsl:template name="DoAddHour">
<xsl:param name='Hour'/>
<xsl:value-of select="$Hour +8"/>
</xsl:template>
<xsl:template name="DoAddDate">
<xsl:param name="Date"/>
<xsl:value-of select="$Date +1"/>
</xsl:template>
<xsl:template name="DoAddYear">
<xsl:param name="Year"/>
<xsl:value-of select="$Year+ 1"/>
</xsl:template>*
*<xsl:template name="DoAddOneDay">
<xsl:param name="DoDay"/>
<xsl:variable name="DayInAWeek" select="$DoDay"/>
<xsl:choose>
<xsl:when test="$DayInAWeek = 'Sun'">Mon</xsl:when>
<xsl:when test="$DayInAWeek = 'Mon'">Tue</xsl:when>
<xsl:when test="$DayInAWeek = 'Tue'">Wed</xsl:when>
<xsl:when test="$DayInAWeek = 'Wed'">Thu</xsl:when>
<xsl:when test="$DayInAWeek = 'Thu'">Fri</xsl:when>
<xsl:when test="$DayInAWeek = 'Fri'">Sat</xsl:when>
<xsl:when test="$DayInAWeek = 'Sat'">Sun</xsl:when>
</xsl:choose>
</xsl:template>*
* <xsl:template name="DoAddOneMonth">
<xsl:param name="DoMonth"/>
<xsl:variable name="MonthInAYear" select="$DoMonth"/>
<xsl:choose>
<xsl:when test="$MonthInAYear = 'Jan'">Feb</xsl:when>
<xsl:when test="$MonthInAYear = 'Feb'">Mar</xsl:when>
<xsl:when test="$MonthInAYear = 'Mar'">Apr</xsl:when>
<xsl:when test="$MonthInAYear = 'Apr'">May</xsl:when>
<xsl:when test="$MonthInAYear = 'May'">Jun</xsl:when>
<xsl:when test="$MonthInAYear = 'Jun'">Jul</xsl:when>
<xsl:when test="$MonthInAYear = 'Jul'">Aug</xsl:when>
<xsl:when test="$MonthInAYear = 'Aug'">Sep</xsl:when>
<xsl:when test="$MonthInAYear = 'Sep'">Oct</xsl:when>
<xsl:when test="$MonthInAYear = 'Oct'">Nov</xsl:when>
<xsl:when test="$MonthInAYear = 'Nov'">Dec</xsl:when>
<xsl:when test="$MonthInAYear = 'Dec'">Jan</xsl:when>
</xsl:choose>
</xsl:template>*


*This was not the best solution for my problem , but i had to resort to a
workaround because of the limitation of the system i was trying to add
content to. :0*
*I know this was a bit different bbut i hope i help you with an idea,..
keep me posted. ^_^*





On 10/13/08, stylus-studio-xslt Listmanager <
stylus-studio-xslt.listmanager@stylusstudio.com> wrote:
>
> From: tyler horath
>
> anyway that will work is fine by me. I just want the date to start at the
> current time on the first node, then to keep adding an hour to each node.
>
> <example>
> <item>
> <pubdate>10-13-2008 8:00</pubdate>
> </item>
> <item>
> <pubdate>10-13-2008 9:00</pubdate>
> </item>
> <item>
> <pubdate>10-13-2008 10:00</pubdate>
> </item>
> <item>
> <pubdate>10-13-2008 11:00</pubdate>
> </item>
> <item>
> <pubdate>10-13-2008 12:00</pubdate>
> </item>
> <item>
> <pubdate>10-14-2008 1:00</pubdate>
> </item>
> </example>
>
> and so on...
>
> And in doing this hopefully the days will change as the hours pass 24 or
> whatever.
>
>
> --
> To reply:stylus-studio-xslt.25319@stylusstudio.com
> To start a new topic:stylus-studio-xslt@stylusstudio.com
> To login:http://www.stylusstudio.com/SSDN/
> To (un)subscribe:stylus-studio-xslt.list-request@stylusstudio.com
>



--
"We can observe and theorize. But we can never know how. Reality is
something we can only approach"-albert enstein's pen

Postnext
tyler horathSubject: Re: xsl date time adding...
Author: tyler horath
Date: 14 Oct 2008 12:40 PM
so I would just call those templates where i wanted to put the date time?

Postnext
(Deleted User) Subject: Re: xsl date time adding...
Author: (Deleted User)
Date: 14 Oct 2008 05:55 PM
yes. If this is how you would like to achieve your goal.

On Wed, Oct 15, 2008 at 12:42 AM, stylus-studio-xslt Listmanager <
stylus-studio-xslt.listmanager@stylusstudio.com> wrote:

> From: tyler horath
>
> so I would just call those templates where i wanted to put the date time?
>
>
> --
> To reply:stylus-studio-xslt.25326@stylusstudio.com
>
> To start a new topic:stylus-studio-xslt@stylusstudio.com
> To login:http://www.stylusstudio.com/SSDN/
> To (un)subscribe:stylus-studio-xslt.list-request@stylusstudio.com
>



--
"We can observe and theorize. But we can never know how. Reality is
something we can only approach"-albert enstein

Postnext
tyler horathSubject: Re: xsl date time adding...
Author: tyler horath
Date: 14 Oct 2008 07:51 PM
Originally Posted: 14 Oct 2008 07:15 PM
Isnt there just a way to use add:date to some sort of loop?

Postnext
(Deleted User) Subject: Re: xsl date time adding...
Author: (Deleted User)
Date: 15 Oct 2008 05:38 AM
i think there is . try to research about EXSLT extensions.
http://www.exslt.org/func/ Then when you already know how you can integrate
datetime functions, you can just use it while looping through the nodes
that you need to add 24 hours to.

On 10/15/08, stylus-studio-xslt Listmanager <
stylus-studio-xslt.listmanager@stylusstudio.com> wrote:
>
> From: tyler horath
>
> Isnt there just a way to use add:date to some sort of loop?
>
>
>
> --
> To reply:stylus-studio-xslt.25329@stylusstudio.com
> To start a new topic:stylus-studio-xslt@stylusstudio.com
> To login:http://www.stylusstudio.com/SSDN/
> To (un)subscribe:stylus-studio-xslt.list-request@stylusstudio.com
>



--
"We can observe and theorize. But we can never know how. Reality is
something we can only approach"-albert enstein's Pen

Postnext
tyler horathSubject: Re: xsl date time adding...
Author: tyler horath
Date: 17 Oct 2008 04:54 PM
tried this with no luck...

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:fn="http://www.w3.org/2005/xpath-functions"
xmlns:a="http://webservices.amazon.com/AWSECommerceService/2005-10-05"
xmlns:b="http://webservices.amazon.com/AWSECommerceService/2008-08-19"
xmlns:dp="http://www.dpawson.co.uk"
xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"

>
<xsl:import href="date.add.template.xsl" />
<xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />

<xsl:template match="/">
<xsl:call-template name="for.loop">
<xsl:with-param name="i"><xsl:value-of select="xs:dateTime('2008-10-17T12:00:00')"/></xsl:with-param>
<xsl:with-param name="count"><xsl:value-of select="xs:dateTime('2010-10-17T12:00:00')"/></xsl:with-param>
</xsl:call-template>
</xsl:template>


<!-- Rename "old name" elements to "new name" -->
<xsl:template name="for.loop">
<xsl:param name="i"/>
<xsl:param name="count"/>
<xsl:if test="$i &lt;= $count">
<!-- body of the loop goes here -->
</xsl:if>
<xsl:if test="$i &lt;= $count">
<xsl:call-template name="for.loop">

<xsl:with-param name="i">
<!-- Increment index-->
<xsl:value-of select="xs:dateTime('2008-10-17T12:00:00') +
xs:dayTimeDuration('PTD')"/>
</xsl:with-param>
<xsl:with-param name="count">
<xsl:value-of select="$count"/>
</xsl:with-param>
</xsl:call-template>
</xsl:if>
</xsl:template>



</xsl:stylesheet>

Posttop
(Deleted User) Subject: Re: xsl date time adding...
Author: (Deleted User)
Date: 18 Oct 2008 02:41 AM
ok. i guess i didn't help you. Can you give me the sample of your worlk?
just a sample of the node or xml file you are trying to convert..
your expected output? and your solution?
and is the structure of your xml file the same throughout? .. etc.
Let me try to solve it.. (just a try.)



On 10/17/08, stylus-studio-xslt Listmanager <
stylus-studio-xslt.listmanager@stylusstudio.com> wrote:
>
> From: tyler horath
>
> tried this with no luck...
>
> <?xml version="1.0" encoding="UTF-8"?>
> <xsl:stylesheet version="2.0" xmlns:xsl="
> http://www.w3.org/1999/XSL/Transform"<">http://www.w3.org/1999/XSL/Transform>xmlns:xs="
> http://www.w3.org/2001/XMLSchema" <http://www.w3.org/2001/XMLSchema>
> xmlns:fn="http://www.w3.org/2005/xpath-functions"<http://www.w3.org/2005/xpath-functions>
> xmlns:a="http://webservices.amazon.com/AWSECommerceService/2005-10-05"<http://webservices.amazon.com/AWSECommerceService/2005-10-05>
> xmlns:b="http://webservices.amazon.com/AWSECommerceService/2008-08-19"<http://webservices.amazon.com/AWSECommerceService/2008-08-19>
> xmlns:dp="http://www.dpawson.co.uk" <http://www.dpawson.co.uk/>
> xmlns:xdt="http://www.w3.org/2005/02/xpath-datatypes"<http://www.w3.org/2005/02/xpath-datatypes>
>
> >
> <xsl:import href="date.add.template.xsl" />
> <xsl:output method="xml" version="1.0" encoding="UTF-8" indent="yes" />
>
> <xsl:template match="/">
> <xsl:call-template name="for.loop">
> <xsl:with-param name="i"><xsl:value-of
> select="xs:dateTime('2008-10-17T12:00:00')"/></xsl:with-param>
> <xsl:with-param name="count"><xsl:value-of
> select="xs:dateTime('2010-10-17T12:00:00')"/></xsl:with-param>
> </xsl:call-template>
> </xsl:template>
>
>
> <!-- Rename "old name" elements to "new name" -->
> <xsl:template name="for.loop">
> <xsl:param name="i"/>
> <xsl:param name="count"/>
> <xsl:if test="$i &lt;= $count">
> <!-- body of the loop goes here -->
> </xsl:if>
> <xsl:if test="$i &lt;= $count">
> <xsl:call-template name="for.loop">
>
> <xsl:with-param name="i">
> <!-- Increment index-->
> <xsl:value-of select="xs:dateTime('2008-10-17T12:00:00') +
> xs:dayTimeDuration('PTD')"/>
> </xsl:with-param>
> <xsl:with-param name="count">
> <xsl:value-of select="$count"/>
> </xsl:with-param>
> </xsl:call-template>
> </xsl:if>
> </xsl:template>
>
>
>
> </xsl:stylesheet>
>
>
>
> --
> To reply:stylus-studio-xslt.25340@stylusstudio.com
> To start a new topic:stylus-studio-xslt@stylusstudio.com
> To login:http://www.stylusstudio.com/SSDN/
> To (un)subscribe:stylus-studio-xslt.list-request@stylusstudio.com
>



--
"We can observe and theorize. But we can never know how. Reality is
something we can only approach"-albert enstein's Pen

   
Download A Free Trial of Stylus Studio 6 XML Professional Edition Today! Powered by Stylus Studio, the world's leading XML IDE for XML, XSLT, XQuery, XML Schema, DTD, XPath, WSDL, XHTML, SQL/XML, and XML Mapping!  
go

Log In Options

Site Map | Privacy Policy | Terms of Use | Trademarks
Stylus Scoop XML Newsletter:
W3C Member
Stylus Studio® and DataDirect XQuery ™are from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2016 All Rights Reserved.