Combining values in xslt

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ceviz
    New Member
    • May 2010
    • 1

    Combining values in xslt

    Hi there,
    I am pretty new to XML and XSLT concepts. I am working on a project which uses a XML file to retrieve values and display them. The concept of XML file is like,

    Code:
    <root>
    	<customer>[INDENT]	<id></id>
    	<name></name>
    	<number></number>
    	<day></day>
    	<month></month>
    	<year></year>[/INDENT]
    	</customer>
    </root>
    <!-- Editor’s note: the <customer> tags don’t make sense this way,
    but I left the code as it is  -->
    <!-- Ceviz: corrected the mistypnig -->
    Now, as you see i have seperated the date variables as day, month and year. Because, i have asked to prepare 3 pages like
    1.customers who visited today.
    2.customers who visited this week.
    3.customer who visited within this year.

    my instincts says i need to get the date of this day and compare with dd.mm.yy and if it checks i have to display the values etc..:)
    so, is there any way to achive it? If yes, then how?

    Thanks in advance
    Last edited by Dormilich; May 15 '10, 11:41 PM. Reason: Please use [code] tags when posting code
  • jkmyoung
    Recognized Expert Top Contributor
    • Mar 2006
    • 2057

    #2
    Day, month, year comparison in xslt are always horrible. If you can, I would pass in 2 sets of parameters to the xslt.
    1. Today's date.
    2. Date from 6 days ago

    You can easily get last year's date from today's date. The reason I suggest 2 seperately, is because of the possible month/year regrouping.

    Comparing dates: start <=? date
    (date.year > start.year) ||
    (date.year == start.year && date.month > start.month) ||
    (date.year == start.year && date.month == start.month && date.day >= start.day)

    So, it's a really ugly expression.

    Comment

    Working...