PDA

View Full Version : XSl If Date has passed dont display


Firerouge
09-22-2009, 08:24 PM
I have an xml file linked to an XSL style sheet. The layout of the xml is currently:

event
news
title
date
info


I have the xsl sheet to display this info and re-order it by date.

What I want is it not to display the news article if the date (stored in 09/22/09 format) is already past.

I dont want to have to manly change it every day telling it the new date, I also dont want to re-work the system to use databases.

I do have cron jobs at my dissposal to use though.

Firerouge
09-23-2009, 04:53 AM
Please help as this is important to get done ASAP.

Alex Vincent
09-23-2009, 09:50 PM
Can you provide the source code, or an excerpt with the relevant parts?

Firerouge
09-24-2009, 02:21 AM
Can you provide the source code, or an excerpt with the relevant parts?


An exert of the XML file that contains the news events:
<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="news.xsl"?>
<events>
<news>
<title>Website Released</title>
<date>09/23/09</date>
<info>The official release of website!</info>
</news>
</events>



An exert of the XSL file that adds the styling cut out the non-important stuff:
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="http://www.twtalon.net/school/news.xml" -->
<!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY tmdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<style>
body.inset {
border-style:ridge;
border-width:6px;
border-color:#F00;
}
</style>
</head>


<body class="inset" style="font-family:Arial;font-size:12pt;background-color:#1D1D1D">
<xsl:for-each select="events/news">
<xsl:sort select="date"/>

<div style="background-color:red;color:white;padding:4px">
<span style="font-weight:bold"><xsl:value-of select="title"/></span>
- <xsl:value-of select="date"/>
</div>

<div style="color:#B8B8B8">
<xsl:value-of select="info"/>
</div>
<br />
</xsl:for-each>
</body>
</html>

</xsl:template>
</xsl:stylesheet>

What do I add to the XSL file to make it only display dates after the current date.

Firerouge
09-28-2009, 07:53 PM
Still need help.

oesxyl
10-02-2009, 03:04 AM
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:date="http://exslt.org/dates-and-times">

<xsl:output method="html"
encoding="utf-8"
doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN"
doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>

<xsl:template match="/">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<!-- .... -->
</head>
<body>
<xsl:apply-template select="events/news[date = date:date()]"/>
</body>
</html>
</xsl:template>

<xsl:template match="news">
<!-- ... -->
</xsl:template>
</xsl:stylesheet>


for different datetime function look to this link:

http://exslt.org/date/index.html

best regards

Firerouge
10-02-2009, 05:41 AM
for different datetime function look to this link:

http://exslt.org/date/index.html

best regards

Thank you so much! Finally an answer.