How to format gMonth?

H

howa

<report month="--07--">

in XSLT, how to format to e.g. Jul

I have tried using format-date but didn;t work

p.s. I am using saxon 8
 
J

Joe Kesselman

howa said:
<report month="--07--">
in XSLT, how to format to e.g. Jul

Table lookup, as in any other programming language. Extract the number,
use it to index into a table of strings.

For example, set up a string "JanFebMarAprMay..." and using substring
(subtract one from month number, multiply by three, use that as the
starting offset and 3 as the length).

Some other approaches are shown in
http://www.dpawson.co.uk/xsl/sect2/N4995.html

(Obviously, you'll also need to use substring or something like it to
extract the month digits from that value.)
 
H

howa

Table lookup, as in any other programming language. Extract the number,
use it to index into a table of strings.

yeah, this must work sure.

but as i am using XSLT 2.0, i believe i have a better way to do it? Or
why should I use gMonth in the schema?

I can just simply use a integer or string.

Thanks anyway
 
J

Joe Kesselman

howa said:
or why should I use gMonth in the schema?

You asked what the Schema-standard way to represent a month is.
gMonth is it.

You use it the same reason you use other schema types -- because you
want schema to check that it's in the right range, and/or because you
want schema-aware applications to automatically do something reasonable
with it.
I can just simply use a integer or string.

You certainly can. You can even use an integer that's limited to the
1-12 range, or a string that is one of a limited set of values, if you
set the schema up appropriately. But then nobody but you knows what its
semantic meaning is. That may or may not matter to you, depending on
what you're doing with the data now and what you intend to do with it in
the future.
 

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,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top