Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > How to format gMonth?

Reply
Thread Tools

How to format gMonth?

 
 
howa
Guest
Posts: n/a
 
      10-13-2007
<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

 
Reply With Quote
 
 
 
 
Joe Kesselman
Guest
Posts: n/a
 
      10-13-2007
howa wrote:
> <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.)


--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
 
howa
Guest
Posts: n/a
 
      10-13-2007
On 10 13 , 11 42 , Joe Kesselman <(E-Mail Removed)> wrote:
> howa wrote:
> > <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.
>


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

 
Reply With Quote
 
Martin Honnen
Guest
Posts: n/a
 
      10-13-2007
howa wrote:
> <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


I browsed through
<URL:http://www.saxonica.com/documentation/functions/intro.html> but
there does not seem to be a predefined XPath or XSLT function for what
you want to achieve.
You might want to ask on the XSL mailing list
<URL:http://www.mulberrytech.com/xsl/xsl-list/> to make sure.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 
Reply With Quote
 
Joe Kesselman
Guest
Posts: n/a
 
      10-13-2007
howa wrote:
> 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.

--
() ASCII Ribbon Campaign | Joe Kesselman
/\ Stamp out HTML e-mail! | System architexture and kinetic poetry
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Money Format + Decimal Place Format shannon Java 1 02-02-2006 03:47 PM
need code to convert float format to internal java float format which is kept in 4 bytes integer Andy Java 7 05-10-2004 09:26 PM
NTFS quick format and normal format Guan Foo Wah MCSE 2 05-08-2004 11:35 PM
Date Format - best way of converting a string into a date format Brian Candy ASP .Net 2 02-18-2004 02:13 PM



Advertisments