newbie XSLT question

Discussion in 'XML' started by sixstringdork@gmail.com, Jul 9, 2007.

  1. Guest

    I'm new to XML/XSLT. I have most of my transform working, but I have
    some data enclosed with "edit" tags that need to be used to control
    what HTML gets displayed. Here's a snippet of my XML:

    <?xml version="1.0" encoding="iso-8859-1"?>
    <rootCode>
    <rootCodeTitle startDate='19781001'
    endDate='99999999'><title>Chocolate Milk</title>
    <chapter><title>CHAPTER 1. GENERAL PROVISIONS</title>
    <subsec1><title>102. Rules of construction</title>
    <subsec2>
    <para>In this title</para>
    <subsec3>
    <title>(7)</title>
    <para>the cow jumped over the moon;<edit startDate='19791001'
    endDate='19861125'>and</edit><edit startDate='19861126'
    endDate='99999999'></edit></para>
    </subsec3>
    <subsec3>
    <title>(8)</title>
    <para>the house, <edit startDate='19701001'
    endDate='19831002'>continued</edit><edit startDate='19831002'
    endDate='99999999'>contained</edit> a glass of milk<edit
    startDate='19701001' endDate='19851125'>.</edit><edit
    startDate='19851126' endDate='99999999'>; and</edit></para>
    </subsec3>
    <subsec3 startDate='19851126' endDate='99999999'><title >(9)</
    title>
    <para>When to shake the jug.</para>
    </subsec3>
    </subsec2>
    </subsec1>
    </chapter>
    </rootCodeTitle>
    </rootCode>

    I'm passing an XSL parameter such as code_rev_date = '19800101' (a
    date converted to a number). I want to display the text as it existed
    on that date (the parameter date).

    So I want to show, for example, most of /subsec3/para, but omit the
    text that came after 19831002 (based on a parameter of 19800101. I've
    been drifting around on W3.org, etc. for several days and I'm not
    having much luck on how to approach this.

    I hope this make sense. I can post my XSL sheet, but I don't think it
    will be much help since it sucks.
    (using classic ASP and IIS if it matters)

    Thanks and sorry for the newbie question.
     
    , Jul 9, 2007
    #1
    1. Advertising

  2. Start with the identity stylesheet. (Look in the XSLT spec, or websearch
    to find a copy of this; it's a near-universal starting point for writing
    XSLT stylesheets.)

    Modify it by adding a template which matches on elements which have a
    @startDate after, or an @endDate before, the date you're interested in,
    and which generates no output (thus discarding those elements and all
    their contents).


    Or am I misunderstanding your question?


    --
    () ASCII Ribbon Campaign | Joe Kesselman
    /\ Stamp out HTML e-mail! | System architexture and kinetic poetry
     
    Joe Kesselman, Jul 10, 2007
    #2
    1. Advertising

  3. Guest

    That's it. Thanks. I have it half way there now. My sheet drops the
    stuff that falls outside of the relevant dates, but I'm trying to get
    the formatting right on what's left. I REALLY feel stupid with this
    stuff. I've been writing .asp code for almost 10 years and am really
    comfortable doing it, but my brain is seriously broken when it comes
    to this XSLT stuff (maybe I'm just getting old).

    This isn't really a question. Just a thanks to let you know that I
    got your message and that it helped moved me forward. My real
    problem, I think, is that I'm trying to learn XML AND XSLT at the same
    time. I just need to slow down and do some real reading I think.
    It's just my nature to slog through code until I learn something.

    Thanks.
    :)
     
    , Jul 11, 2007
    #3
  4. wrote:
    > I've been writing .asp code for almost 10 years and am really
    > comfortable doing it, but my brain is seriously broken when it comes
    > to this XSLT stuff (maybe I'm just getting old).


    Rule-based programming does seem to be hard for folks to learn... but
    it's a really powerful idiom once you get used to it.

    > I think, is that I'm trying to learn XML AND XSLT at the same
    > time. I just need to slow down and do some real reading I think.


    Being thrown into the deep end of the pool sometimes works; depends on
    how good you are at reading other programmers' minds, and how good you
    are at researching the problems as you encounter them.

    Remember to have fun... <smile/>

    --
    Joe Kesselman / Beware the fury of a patient man. -- John Dryden
     
    Joseph Kesselman, Jul 11, 2007
    #4
  5. Peter Flynn Guest

    wrote:
    > I'm new to XML/XSLT. I have most of my transform working, but I have
    > some data enclosed with "edit" tags that need to be used to control
    > what HTML gets displayed. Here's a snippet of my XML:
    >
    > <?xml version="1.0" encoding="iso-8859-1"?>
    > <rootCode>
    > <rootCodeTitle startDate='19781001'
    > endDate='99999999'><title>Chocolate Milk</title>
    > <chapter><title>CHAPTER 1. GENERAL PROVISIONS</title>
    > <subsec1><title>102. Rules of construction</title>
    > <subsec2>
    > <para>In this title</para>
    > <subsec3>
    > <title>(7)</title>
    > <para>the cow jumped over the moon;<edit startDate='19791001'
    > endDate='19861125'>and</edit><edit startDate='19861126'
    > endDate='99999999'></edit></para>
    > </subsec3>
    > <subsec3>
    > <title>(8)</title>
    > <para>the house, <edit startDate='19701001'
    > endDate='19831002'>continued</edit><edit startDate='19831002'
    > endDate='99999999'>contained</edit> a glass of milk<edit
    > startDate='19701001' endDate='19851125'>.</edit><edit
    > startDate='19851126' endDate='99999999'>; and</edit></para>
    > </subsec3>
    > <subsec3 startDate='19851126' endDate='99999999'><title >(9)</
    > title>
    > <para>When to shake the jug.</para>
    > </subsec3>
    > </subsec2>
    > </subsec1>
    > </chapter>
    > </rootCodeTitle>
    > </rootCode>
    >
    > I'm passing an XSL parameter such as code_rev_date = '19800101' (a
    > date converted to a number). I want to display the text as it existed
    > on that date (the parameter date).


    I hate to pour cold water on this, but this type of requirement has been
    solved in other ways long ago, notably with DocBook's effectivity
    attributes and with numerous historical synchronisation and layering
    methods developed for the TEI DTD.

    ///Peter
    --
    XML FAQ: http://xml.silmaril.ie/
     
    Peter Flynn, Jul 14, 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. Stylus Studio
    Replies:
    0
    Views:
    775
    Stylus Studio
    Aug 3, 2004
  2. Benjamin Hillsley
    Replies:
    3
    Views:
    1,751
    Dimitre Novatchev
    Sep 25, 2003
  3. ted
    Replies:
    1
    Views:
    655
    Laurens
    Jan 26, 2004
  4. Replies:
    2
    Views:
    742
    Henry S. Thompson
    Oct 19, 2005
  5. Replies:
    18
    Views:
    2,816
    Joseph Kesselman
    Oct 4, 2006
Loading...

Share This Page