How to format gMonth?

Discussion in 'XML' started by howa, Oct 13, 2007.

  1. howa

    howa Guest

    <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
     
    howa, Oct 13, 2007
    #1
    1. Advertising

  2. 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
     
    Joe Kesselman, Oct 13, 2007
    #2
    1. Advertising

  3. howa

    howa Guest

    On 10 13 , 11 42 , Joe Kesselman <> 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
     
    howa, Oct 13, 2007
    #3
  4. 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/
     
    Martin Honnen, Oct 13, 2007
    #4
  5. 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
     
    Joe Kesselman, Oct 13, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,174
    Janaka
    Feb 18, 2004
  2. Andy
    Replies:
    7
    Views:
    6,277
    Roedy Green
    May 10, 2004
  3. shannon
    Replies:
    1
    Views:
    8,605
  4. shannon
    Replies:
    0
    Views:
    575
    shannon
    Feb 1, 2006
  5. Lord0
    Replies:
    2
    Views:
    646
    Lord0
    Oct 20, 2006
Loading...

Share This Page