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"/>
</xsl:apply-templates>
</xsl:template>
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[(_at_)highlight_date < $sysdate]
this works, but stay away from xsl:for-each until you uinderstand what
you are doing.
//item
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[(_at_)highlight_date < $sysdate]
//item[(_at_)highlight_date >= $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() < 6">
<xsl:apply-templates/>
</xsl:if>
</xsl:template>
<>
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.
best,
-Rob
<>
Thanks again,
-John