XML dates

A

adam bob

Hello, i'm currently working on some xslt that formats some xml gained
from an infopath form. The problem i have is the date. Basically its
generatng the date in this format; 2007-09-04 00:00:00. Ideally i'd
like the date to be in the following format; 12-aug-2007, or
14/07/2007 etc.

I've tried applying numerous templates etc gained from the internet,
but none of them seem to work, or contain errors so my xslt doesnt
parse.

the code;

____________________________________________________________________________________________

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/
myXSD/2007-01-25T08:56:14">
<xsl:eek:utput method="html"/>
<xsl:template match="/">


<html>

<!-- CSS Declaration-->

<style type="test/css">
#style1
{
}


</style>

<body>
<font size="4">
IT project test
</font>

<br></br>
<br></br>

<table style="width: 100%">
<tr>
<td>
<!-- Gets the description from the saved
form -->

<font size="2">

<xsl:value-of select="my:myFields/
my:project_name"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:priority"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:project_sponsor"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:project_owner"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:project_category"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:start_date"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:est_finish"/>

</font>

</td>
</tr>

</table>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

____________________________________________________________________________________________

Please help!!

Many thanks

Adam
 
M

Martin Honnen

adam said:
Hello, i'm currently working on some xslt that formats some xml gained
from an infopath form. The problem i have is the date. Basically its
generatng the date in this format; 2007-09-04 00:00:00. Ideally i'd
like the date to be in the following format; 12-aug-2007, or
14/07/2007 etc.

I am not sure which XSLT processor infopath uses but it might be MSXML
5. With MSXML you have extension functions to format dates and times
e.g. this stylesheet

<xsl:stylesheet
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:ms="urn:schemas-microsoft-com:xslt"
exclude-result-prefixes="ms">

<xsl:template match="/">
<example><xsl:value-of select="ms:format-date('2007-09-04',
'dd-MMM-yyyy', 'en-US')"/></example>
</xsl:template>

</xsl:stylesheet>

outputs

<example>04-Sep-2007</example>

See the documentation of MSXML in the MSXML SDK:
<URL:http://msdn2.microsoft.com/en-us/library/ms763742.aspx> and the
section about format-date:
<URL:http://msdn2.microsoft.com/en-us/library/ms256099.aspx>
 
A

adam bob

Hello, i'm currently working on some xslt that formats some xml gained
from an infopath form. The problem i have is the date. Basically its
generatng the date in this format; 2007-09-04 00:00:00. Ideally i'd
like the date to be in the following format; 12-aug-2007, or
14/07/2007 etc.

I've tried applying numerous templates etc gained from the internet,
but none of them seem to work, or contain errors so my xslt doesnt
parse.

the code;

___________________________________________________________________________­_________________

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/
myXSD/2007-01-25T08:56:14">
<xsl:eek:utput method="html"/>
<xsl:template match="/">

<html>

<!-- CSS Declaration-->

<style type="test/css">
#style1
{
}

</style>

<body>
<font size="4">
IT project test
</font>

<br></br>
<br></br>

<table style="width: 100%">
<tr>
<td>
<!-- Gets the description from the saved
form -->

<font size="2">

<xsl:value-of select="my:myFields/
my:project_name"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:priority"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:project_sponsor"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:project_owner"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:project_category"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:start_date"/>

<br></br>
<br></br>

<xsl:value-of select="my:myFields/
my:est_finish"/>

</font>

</td>
</tr>

</table>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

___________________________________________________________________________­_________________

Please help!!

Many thanks

Adam

I've tried this but i still get errors. My xslt is gaining the data
from an external xml document generated by an infopath form. So the
date defaults to this format. So i need a way of manipulating the date
captured in order to display like dd/mm/yyyy. I guess i have to use
some kind of template, but i've tried adding some from the internet,
but they contain errors like ' template cannot be a child of body tag,
or font tag etc etc. I've tried removing these tags up until the point
there is bearly any code left.

______________________________________________________________________________________________________________________________________

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/
myXSD/2007-01-25T08:56:14">
<xsl:eek:utput method="html"/>
<xsl:template match="/">


<html>

<head>

<!-- CSS Declaration-->

<style type="text/css">
.style1
{
font-family: Arial, Verdana, Helvetica, Sans-serif;
font-size: 16px;
color: #003399;
font-weight: bold;
}
.style2
{
font-weight: bold;
}
</style>


</head>

<body>

<br></br>

<span class ="style1">Project Dates</span>


<br></br>
<br></br>

<table style="width: 100%">
<tr>
<td>
<!-- Gets the data from the XML source -->

<font size="2">

<span class ="style2">Start
date: </span><xsl:value-of select="my:myFields/my:start_date"/>

<xsl:template name="standard_date">
<xsl:param name="date" />
<!-- Day -->
<xsl:value-of select="substring($date,
7, 2)" />
<xsl:text>/</xsl:text>
<!-- Month -->
<xsl:value-of select="substring($date,
5, 2)" />
<xsl:text>/</xsl:text>
<!-- Year -->
<xsl:value-of select="substring($date,
3, 2)" />
</xsl:template>


<br></br>
<br></br>

<span class ="style2">Estimated
Finish Date: </span><xsl:value-of select="my:myFields/my:est_finish"/>

<br></br>
<br></br>

<span class ="style2">Project
Duration: </span><xsl:value-of select="/my:myFields/my:group1/
my:difference"/>

</font>

</td>
</tr>

</table>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

_____________________________________________________________________________________________________________________________________

Here i've added a template. Maybe i have to re-format the structure?

thanks

Adam
 
B

Ben

I've tried this but i still get errors. My xslt is gaining the data
from an external xml document generated by an infopath form. So the
date defaults to this format. So i need a way of manipulating the date
captured in order to display like dd/mm/yyyy. I guess i have to use
some kind of template, but i've tried adding some from the internet,
but they contain errors like ' template cannot be a child of body tag,
or font tag etc etc. I've tried removing these tags up until the point
there is bearly any code left.

___________________________________________________________________________­___________________________________________________________

<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/
Transform" xmlns:my="http://schemas.microsoft.com/office/infopath/2003/
myXSD/2007-01-25T08:56:14">
<xsl:eek:utput method="html"/>
<xsl:template match="/">

<html>

<head>

<!-- CSS Declaration-->

<style type="text/css">
.style1
{
font-family: Arial, Verdana, Helvetica, Sans-serif;
font-size: 16px;
color: #003399;
font-weight: bold;
}
.style2
{
font-weight: bold;
}
</style>

</head>

<body>

<br></br>

<span class ="style1">Project Dates</span>

<br></br>
<br></br>

<table style="width: 100%">
<tr>
<td>
<!-- Gets the data from the XML source -->

<font size="2">

<span class ="style2">Start
date: </span><xsl:value-of select="my:myFields/my:start_date"/>

<xsl:template name="standard_date">
<xsl:param name="date" />
<!-- Day -->
<xsl:value-of select="substring($date,
7, 2)" />
<xsl:text>/</xsl:text>
<!-- Month -->
<xsl:value-of select="substring($date,
5, 2)" />
<xsl:text>/</xsl:text>
<!-- Year -->
<xsl:value-of select="substring($date,
3, 2)" />
</xsl:template>

<br></br>
<br></br>

<span class ="style2">Estimated
Finish Date: </span><xsl:value-of select="my:myFields/my:est_finish"/>

<br></br>
<br></br>

<span class ="style2">Project
Duration: </span><xsl:value-of select="/my:myFields/my:group1/
my:difference"/>

</font>

</td>
</tr>

</table>

</body>
</html>

</xsl:template>
</xsl:stylesheet>

___________________________________________________________________________­__________________________________________________________

Here i've added a template. Maybe i have to re-format the structure?

thanks

Adam- Hide quoted text -

- Show quoted text -

Hello there bob? :D

it sounds like what youre looking for is a substring operator to cut
that datetime down

heres a usefull link that might help

http://articles.techrepublic.com.com/5100-22-1054414.html

regards

Ben
 
N

Nicolas George

adam bob wrote in message
Hello, i'm currently working on some xslt that formats some xml gained
from an infopath form. The problem i have is the date. Basically its
generatng the date in this format; 2007-09-04 00:00:00. Ideally i'd
like the date to be in the following format; 12-aug-2007, or
14/07/2007 etc.

In terms of logic and usability, "2007-09-04" is better than "14/07/2007"
(because the digits are in weight order), which is better than "12-aug-2007"
(because it requires a table lookup).

And please, do not forget to include a time zone in your time format.
 
J

Joe Kesselman

Personally, I would recommend that dates in XML be expressed in a format
compatible with that of the XML Schema date/time datatypes, since that
gives you the best odds that off-the-shelf tools will be able to help
you manipulate them (in the future, if not now).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,521
Members
44,995
Latest member
PinupduzSap

Latest Threads

Top