Get year from dateTime

P

Pravljica

Hello,

I don't know how to get year from dateTime.

My xml:
<P>
<A>
<Time>
<TimeBeginning>2006-04-01T08:00:00</TimeBeginning>
</Time>
</A>
</P>

Now I have this, but it does not work.
<xsl:for-each select="P/A">
<p><xsl:value-of select="year-from-dateTime(Time/TimeBeginning)"
/></p>
</xsl:for-each>

All dates in xml are in this format (2006-04-01T08:00:00).

Can you help me?
Thanks
 
J

Joe Kesselman

First question: Are you using an XSLT 2.0 processor? 1.0 doesn't have
any built-in support for schema datatypes, and would need an assist from
an extension function.
 
P

Pravljica

I really don't know. I am writing this in Notepad and watching in
firefox 1.5.0.3.
Where can I see which XSLT processor I use?
 
M

Martin Honnen

Pravljica said:
I really don't know. I am writing this in Notepad and watching in
firefox 1.5.0.3.
Where can I see which XSLT processor I use?

Firefox 1.5 (well all current Firefox versions) use Transformiix as an
XSLT processor and that processor supports XSLT 1.0 and XPath 1.0.
Any date, time, dateTime functions are part of XPath 2.0 and not
supported by Firefox's built-in processor.
You would need to use Saxon 8 from http://www.saxonica.com/ if you want
an XSLT 2.0 processor.
On the other hand extracting the year is easy with XPath 1.0 string
functions
substring(Time/TimeBeginning, 1, 4)
 
P

Pravljica

Thanks Martin, this works.

I have also instaled MSXML 4.0 SP2 Parser and SDK. Is this in some
connection with XSLT processor?

If I install saxonica - will my documents work on computers that don't
have saxonica installed? Probably not :)
 
M

Martin Honnen

Pravljica wrote:

I have also instaled MSXML 4.0 SP2 Parser and SDK. Is this in some
connection with XSLT processor?

MSXML 4 has an XSLT 1.0 processor.
If I install saxonica - will my documents work on computers that don't
have saxonica installed? Probably not :)

The company is named Saxonica, the XSLT processor is called Saxon. And
yes, Saxon 8 needs to be installed to allow for XSLT 2.0 processing. So
far XSLT 2.0 is only a candidate recommendation, once it has become a
W3C recommendation it is likely there will be other implementations
besides Saxon.
 

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
474,002
Messages
2,570,258
Members
46,857
Latest member
ArleenWill

Latest Threads

Top