Re: [xsl] Release Date vs. Highlight Until Date

Subject: Re: [xsl] Release Date vs. Highlight Until Date
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Mon, 20 Sep 2004 17:33:21 -0700
Hi John,

Welcome. I will talk about XSLT 1.0, but there are efforts underway for XSLT 2.0 (a saxon 8.0 port to .NET) under development with a few strong proponents here :) Since you are using .NET you should be aware that Micrsoft has made the decision not to support XSLT 2.0 (but that does not stop 3rd parties). (more inline)

xsl-list wrote:

Hi,

I am new to the list and XSL in general, so I apologize if this is the wrong
forum for this question.



You will find this list to be one of the most helpful around (if not *the* most).


I am also simplifying my problem as much as
possible. I am also still at a pretty high level, looking more into the
concepts than the code. While I would appreciate code examples, simple
suggestions of what tokens I should research or URLs with further information
would also be appreciated.



You will find most answers to questions at Dave Pawson's FAQ:
http://www.dpawson.co.uk/xsl/xslfaq.html
but to get the most benefit from the faq you will need to know what you are looking for, so...


Mike Kay's book. _XSLT's Programmer's Reference_ 2cnd Ed is the bible.

Jeni Tennison's _XSLT and XPath On the Edge_ is a great introduction.

G. Ken Holman has some of his book available online and is an excellent teacher. It would be worth it if you want to jump in quick to take at least the three day course that cover's most everything except XSL-FO (for going to PDF -- the next two days cover XSL-FO):
http://www.cranesoftwrights.com/


I am working with a CMS that stores both the
information architecture (like a directory structure) and content (like XML
files inside the directories) as XML which is transformed using XSL to HTML
for distribution to browsers. If what I'm trying to do becomes too
complicated for XML I can use pure .NET code, but I'm wondering what XSL
solutions might be possible.



Quite a bit, especially given what you have to work with -- which sounds alot like what we do.


Each news record has a "release date" value. I am not sure of the format but
hopefully my code could handle multiple formats, or if there is a standard for
date formatting in XML maybe the CMS uses that.



We use the ISO-8601 standard date format (e.g. 2004-09-20T17:11:00 or YYYY-MM-DD [time separator] HH:MM:SS).


On a main page I need to list
the latest 5 article titles based on this "release date", with links to the
article content. That would seem like a simple sort with some kind of break
condition after 5 loops (though I'm not even sure how to do that), but the
complication is that each record also has a "highlight until" date; if the
current system date is before the "highlight until" date, those highlighted
records need to appear at the top of the list, which should still be
constrained to 5 articles.



When dealing with XSL it is good to not think about looping (XSL does require a kind of paradigm shift). What would help is if you could post the XML that you would be using as the source in your transformation. I (and others) don't want to confuse you by guessing at the structure the XSL needs to traverse.


It seems that XSL doesn't inherently know what date it is, so either my CMS
vendor should already be passing that or I need to figure out how to pass this
as a parameter to my XSL. I'm also not finding many web references to this
specific kind of date logic. Based on these I'm wondering if a .NET component
is the right way to go, but since the data is already in XML I think I would
prefer XSL if possible/not too complicated.



Yes, you want to pass the /current date-time/ in as parameter to the transformation. I don't know how to pass this in in .NET but the XSL to accept it would be a global parameter (a child of /xsl:stylesheet).


So you set a parameter on the transformation and catch it in the transformation. If the date parameter was not sent to the transformation it will default to an empty string, ''.


good luck, -Rob


Any assistance would be greatly appreciated.

Thanks,

-John

Current Thread