Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ordering by date

Status
Not open for further replies.

danfood

Programmer
Aug 8, 2001
32
0
0
GB
Does anyone know what date formats <XSL:eek:rder-by> works on?

I have a list of elements and I want to display them using xsl in date order how do I enter my dates in the xml file

dd/mm/yy
dd/mm/yyyy
dd.mm.yy
etc.

Any ideas?

PS
Mr T. I am still struggling with the search engine problem (see my last post) can you help?

Thanks
Dan
 
usually in xml files i've seen the date in the form 20011017 (YYYYMMDD). this is some ISO format and there is an extended version which has the time on the end.
there is also a 2001-10-17 format which is easier on the eyes.
i like the first because you don't need to do anything to prepare for the sort - you just sort it.
you could use any format you want tho, and swap it around in xsl until you get the format above. even formats like &quot;17 feb 2001&quot;.

to sort 17/10/2001
<xsl:sort select=&quot;concat(substring(date,7,4), substring(date,4,2), substring(date,1,2))&quot;>

or to sort 20011017
<xsl:sort select=&quot;date&quot;>
 
But where does one stick it in the code, I have tried several variations on:


<xsl:for-each select=&quot;LUNCHSEMINARS/SEMINAR [DATE >'' and ATTENDANTS =''] &quot;>
<xsl:sort select=&quot;DATE&quot;>

<tr><td> <b>
<xsl:value-of select=&quot;TOPIC&quot;/></span>
</b></td>
</tr>

<td>
<xsl:value-of select=&quot;DATE&quot;/>
</td>
</tr>


<tr><td> <xsl:value-of select=&quot;DESCRIPTION&quot;/></td>
</tr>


<tr><td></td> </tr>

</table>

</table>
</xsl:sort>
</xsl:for-each>

This gives errors when displaying the page.

I have also tried
<xsl:for-each select=&quot;LUNCHSEMINARS/SEMINAR [DATE >'' and ATTENDANTS =''] &quot; sort= &quot;DATE&quot;>

This gives no errors but doesn't sort them!

Dan
 
i'm not sure what the
[DATE >'' and ATTENDANTS ='']
is doing. it would be best to keep things simple and match all &quot;LUNCHSEMINARS/SEMINAR&quot;'s first and worry about the [] later.
i don't understand why the top one gave errors if the bottom one didn't. you're not using the &quot;w3.org/TR/WD-xsl&quot; namespace are you?

:)
 
The
[DATE >'' and ATTENDANTS ='']

is picking out the seminars in the XML BD that are in the future ie where DATE isn't bland and there are no attendees.

Seminars that have happened have had attendees added.


What is wrong with the
w3.org/TR/WD-xsl
namespace.

I don't understand the concept of namespaces what are they?

Also if I am to worry about the [] later would I do this then?



<xsl:for-each select=&quot;LUNCHSEMINARS/SEMINAR&quot;>
<xsl:sort select=&quot;DATE&quot;></xsl:sort>
</xsl:for-each>
ie sort the whole file then filter?

<xsl:for-each select=&quot;LUNCHSEMINARS/SEMINAR [DATE >'' and ATTENDANTS ='']&quot;>
<tr><td> <b>
<xsl:value-of select=&quot;TOPIC&quot;/></span>
</b></td>
</tr>

<td>
<xsl:value-of select=&quot;DATE&quot;/>
</td>
</tr>


<tr><td> <xsl:value-of select=&quot;DESCRIPTION&quot;/></td>
</tr>


<tr><td></td> </tr>

</table>

</table>
</xsl:sort>
</xsl:for-each>




Thanks for your time...

Dan
 
the WD-xsl namespace is some old, out-of-date microsoft implementation that was around before xsl was finalised by w3. it has many problems because a lot of the features aren't supported.
if you look at the table in you'll see that under &quot;msxml2&quot; there is no support for the xsl:sort element. i think WD-xsl = msxml2 and this would explain the error you got. also if you see all the other missing things it should scare you into using the xslt namespace xmlns:xsl=&quot;
all the xmlns:xsl namespace does in the stylesheet is to tell your xsl processor that it is XSLT.
 
I have just put that namespace in and now nothing works!!!!

This is all very strange....
 
I have downloaded the installer of XML core services but my installer on my machine won't run it:

&quot;You must install a windows service pack that contains a newer version of Windows installer&quot;

I'll keep plugging away.

 
I can't install a new service pack from anywhere cos it means I'd have to get a new version of windows. I am currently running windows 95 service pack 2 (the highest for windows 95).

What OS are you running?

This seems a bit strange that the transform won't work with 95.

 
i do all my xsl in linux, and i know little about the windows stuff. all i know is that the default IE5.5 xml stuff should be updated before starting running xsl.
i did upgrade the xml stuff before (on NT) and it seemed to just install no problem. i thought it just did stuff to IE. i think this may be the source of some of our problems (msxml2 doesn't support <xsl:param> either).

maybe you just need it says it's a service pack, but it also says it can be run on a machine without msxml too.
 
Thanks I shall try this and see what happens.

I also couldn't get the the substring or concat functions to work either.
I found the &quot;order-by&quot; works and sorts dates if they are of the form:
YYYYMMDD but then I tried to substring it and concat etc to make it look easier on the eye and display it but I get the &quot;unrecognised method&quot; error when trying to view it in my browser.

Hopefully if I can get the new namespace to work I might get somewhere.

I went out this lunchtime and bought a book on XSL and it makes no mention of the namespace: &quot; not working on some machines/OS systems and I haven't found anything on any other XML/XSL sites.

Can you send me what exactly the top of your XSL pages look like so I can compare?

Until now all mine have been (and will carry on being until I fix it):

<?xml version=&quot;1.0&quot; ?>

<xsl:stylesheet xmlns:xsl=&quot; etc. etc.


I'll keep you posted.

Dan
 
the top of my xsl files always have

<?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?>

<xsl:transform
version=&quot;1.0&quot;
xmlns:xsl=&quot;
if there's a &quot;;&quot; in there somewhere, ignore it (i think tek-tips adds it).

i saw this and it has a link to a sniffer to tell you what msxml is on your machine.

if your still having problems with installing the new stuff then it might be better to start a new thread here and a similar one in the windows group.
 
I have up to and including:

MSXML2 v3.0
installed, this means the transform should work doesn't it?

I am about to send the files to a mate to see if he can get them to work.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top