[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Release Date vs. Highlight Until Date

Subject: Re: Release Date vs. Highlight Until Date
From: Robert Koberg <rob@xxxxxxxxxx>
Date: Mon, 20 Sep 2004 17:56:01 -0700
first condition
xsl-list wrote:

Thanks for your suggestions. I am not sure the CMS vendor supports XSL 2.0. After looking more at the system I think I'll implement an XSL extension to
retrieve sysdate instead of passing it everywhere I need it. I've been
digging deeper and found that the dates are stored as yyyyMMddTHHmmss, which I
don't think is xs:datetime format but should be pretty easy to parse/sort, or
convert to another format for parsing/sorting.

It is the XML Schema date time or xs:dateTime datatype. You are lucky -- this is the easiest to sort, since it allows for simple string sorting. You would do something like:

<xsl:template match="items">
 <xsl:apply-template select="item">
   <xsl:sort select="@release-date"/>

Therefore, since a single XML document contains both the IA and the content, I
think I can do something like (half code, half psuedo-code):

<xsl:variable name="sysdate" select="me:function" />

personally, I would avoid extension functions as much as humanly possible (you don't need them -- I never use them in the CMS, but do when offline for batch processing).

Is it possible to write a single XPath query that merges the equivalent of the
two XPath queries below (excuse my attempt at syntax) such that an
xsl:for-each with that as select will first process the elements matching the
first condition, then those matching the second condition?

//item[@highlight_date &lt; $sysdate]

this works, but stay away from xsl:for-each until you uinderstand what you are doing.


Also, to ensure I don't get the same record twice, do I just reverse the first
condition in the second condition?  Something like:

//item[@highlight_date &lt; $sysdate]

//item[@highlight_date &gt;= $sysdate]

You would want to apply-templates like I have shown above then you can check the position of the node (continuing on my XSL above):

<xsl:template match="item">
 <xsl:if test="position() &lt; 6">

I think that for performance I wouldn't want this combined query to return
more than 5 records. It seems like this would have to do with position(), but
that can only apply before the sort, and I want the 5 records after sort. Any
suggestions? maybe a recursive function? anyway, I have to consider
alternatives for performance.

Then within the xsl:for-each I need to sort such that those records matched by
the highlight_date query appear first - any suggestions there?
Now you can can all see how lost I am.

No, you are getting it, but heading in a wrong direction. Stay away from xsl:for-each.


Thanks again,


Current Thread


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.