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)
-> - XSLT slicing and orphan contro... (1)
-> + How to delete CDATA using XSL... (15)
-> + Remove only root namespace, bu... (3)
-> + String Parsing (3)
-> + Calling Java method from XSL (3)
-> + populate xsl file from xsd fil... (5)
-> + formating a number like #'###.... (3)
-> + Help with grouping children, f... (20)
-> + Need help for newbie! (3)
-> + xpath in string format (2)
-> + How to populate elements at ra... (4)
-> + Changing Date format in XLST (2)
-> + Please help....How could I rem... (2)
-> + Counting children and grandchi... (7)
-> + Nested tags (4)
-> + Problem with XSLT on a Soap En... (2)
-> + Problem with XSLT on a Soap En... (5)
-> + Comparison between XSLT proces... (2)
-> + Printing non-existing value (9)
-> + big input file for XSLT (14)
-> + Is there any way to store xpat... (2)
-> + Encoding special charecters (2)
-> + Sorting (3)
-> + XML to PDF using XSL:FO (3)
-> + How to find the line number in... (2)
-> + How to set a marker for paper ... (2)
-> + Not equality Function (2)
-> + Counting Elements (4)
-> + Looking for help or code samp... (2)
-> + Help needed in pattern matchin... (2)
-> + Repeaters and Ifs (2)
-> + select adjacent nodes in xpath... (3)
-> + Stripping of Empty Target Elem... (2)
-> + auto-generate Edifact Intercha... (5)
-> + Qname Error in xsl:element (2)
-> + [Newbie] Type conversion and f... (2)
-> + Do ...when (2)
-> + Using Key (3)
-> + sorting elements in option (2)
-> + NaN(not available) value repla... (3)
-> + infinite loop error when tryin... (9)
-> + Escape a character in the stri... (3)
-> + find sum of 2 elements in xml (2)
-> + placing a ' * ' by reading the... (3)
-> + Problem in dispaying Current D... (4)
-> + Merging Table Cells in XSLT re... (3)
-> + xsl fo block-container and foo... (2)
-> + Is is possible to create a .CO... (2)
-> + printing a parent node value i... (2)
-> + Mime header info setup? (3)
-> + Calculating a Date based on 4 ... (3)
-> + XSLT formatting number issue (10)
-> + map repeating elements separat... (3)
-> + Combining XML elements based o... (3)
-> + Convert XML to UTF-8 (8)
-> + XSLT and MS Access 2007 Optio... (5)
-> - WORDML list to XML list (1)
-> + [Newbie] Using lookups in XSLT... (3)
-> + Comparing 2 passed Date Values (2)
-> + ERROR XQueryMediator Error du... (2)
-> + XML / XSLT... Unordered lists ... (2)
-> + Specify image path in XSL (2)
-> + Variable within a variable (3)
-> + How to call jfreechart method ... (8)
-> + leading and trailing white spa... (2)
-> + XSLT to Html problems (6)
-> + How to set classpath, when i n... (3)
-> + Error in using functions (4)
-> + To find the occurence of a cha... (3)
-> + PLMXML to XML (4)
-> + Transform multiple node values... (2)
-> + I am in need of svg example(s)... (13)
-> + count in XSLT, Need Help Pleas... (2)
-> + Help with XML.Report and Gener... (2)
-> + for each loop and variable (5)
-> + Problem with selecting nodes f... (3)
-> + Getting "Expected elemenmt mis... (2)
-> + Help with attached XML mapping... (8)
-> + xml:space="Preserve" and Embed... (2)
-> + XSLT and Multiple Strings (2)
-> + XSL Date format (2)
-> + check element contents against... (3)
-> + XML to XML Namespace conversio... (2)
-> - Supressing subgroup headers in... (1)
-> - HTML to fo conversion using XS... (1)
-> + No Topic (2)
-> + parsing xml using xslt HELP (2)
-> + Multiple Page Headers (2)
-> + PLM Xml To Generic XML (3)
-> + XSLT/XPath Help (2)
-> + XSL Space Issue (2)
-> + wanting help with xslt custom ... (3)
-> - Update input xml content with ... (1)
-> + Error: namespace prefix xsl on... (3)
-> + Error in my xsl:if test... (2)
-> - calling javascript from XSLT (1)
-> + Error when trying to a call a ... (2)
-> - HTTP POST from XSLT (1)
-> + passing xml document as input ... (2)
-> + XSLT for WORDML table to CALS ... (2)
-- Previous [361-380] [381-400] [401-420] 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.