XML Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreXML Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old June 14th, 2009, 02:48 PM
ignignokt ignignokt is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 47 ignignokt User rank is Lance Corporal (50 - 100 Reputation Level)ignignokt User rank is Lance Corporal (50 - 100 Reputation Level)ignignokt User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 23 h 26 m 9 sec
Reputation Power: 4
Showing Records Within Last 30 Days

I have a xml file of a directory of video files which I have tagged with the date that the file was added. I would like to create a link on my main page to only show the files that have been added in the last 30 days. The idea is to compare the current date with the date in the added tag and select the records. Any help to get started would be greatly appreciated.

XML File:
Code:
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="main.xsl"?>
<catalog>
  <video>
    <file>
      <label>S</label>
      <name>Sample1.avi</name>
      <size>176 MB</size>
      <created>5/3/2009 7:07:31 AM</created>
      <added>6/11/2009 2:10:23 PM</added>
      <tags />
    </file>
  </video>
  <video>
    <file>
      <label><A/label>
      <name>Ace1.avi</name>
      <size>17 MB</size>
      <created>5/3/2009 8:00:23 AM</created>
      <added>4/11/2008 2:10:23 PM</added>
      <tags />
    </file>
  </video>
</catalog>


XSL File:
Code:
<?xml version='1.0'?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="choice" />
<xsl:output method="html"/>
<xsl:template match="/">

<html>
	<body>		
	<table width="100%" border="1">
	<tbody>
		<tr bgColor="#0033ff">
		<td width="100%">
		<font face="Arial" size="5">
		<font color="#ffffff"><strong>Label - </strong>
		<strong><xsl:value-of select="$choice"/></strong>
		</font>
		</font>
		</td>
		</tr>
	</tbody>
	</table>
	<xsl:for-each select="catalog/video"> 
	<xsl:sort select="file/name"/>
	<xsl:if test="$choice=file/label">
		<xsl:for-each select="file">
		<table width="100%" border="1"><tbody>
			
			<tr bgColor="#005599">

				<td colspan="2">
				<p align="center">
				<font face ="Arial">
				<font color="ffffff">
				<strong>Filename</strong>
				<xsl:value-of select="Filename"/>
				</font>
				</font>
				</p>
				</td>

				<td colspan="2">
				<p align="center">
				<font face ="Arial">
				<font color="ffffff">
				<strong>Size</strong>
				<xsl:value-of select="Filename"/>
				</font>
				</font>
				</p>
				</td>

				<td colspan="2">
				<p align="center">
				<font face ="Arial">
				<font color="ffffff">
				<strong>Date Created</strong>
				<xsl:value-of select="Filename"/>
				</font>
				</font>
				</p>
				</td>

			</tr>
		
			<tr>
				<td colspan="2">
				<p align="center">
				<font face="Arial">
				<xsl:element name = "a">
				<xsl:attribute name="href"><xsl:value-of select="filepath"/>
				</xsl:attribute>
				<xsl:value-of select="name"/>
				</xsl:element>
				</font>
				</p>
				</td>

				<td colspan="2">
				<p align="center">
				<font face="Arial">
				<xsl:value-of select="size"/>
				</font>
				</p>
				</td>

				<td colspan="2">
				<p align="center">
				<font face="Arial">
				<xsl:value-of select="created"/>
				</font>
				</p>
				</td>
			</tr>

			<tr>
				<td><img src="{image01}"/></td>
				<td><img src="{image02}"/></td>
				<td><img src="{image03}"/></td>
				<td><img src="{image04}"/></td>
				<td><img src="{image05}"/></td>
				<td><img src="{image06}"/></td>
			</tr>
			</tbody>
			</table>

			<table width="100%" border="1"><tbody>
			<tr bgColor="#666666">
				
				<td colspan="1">
				<p align="left">
				<font face="Arial" size="2.5">
				<font color="ffffff">
				<strong>Tags</strong>
				</font>
				</font>
				</p>
				</td>

			</tr>

			<tr>
				<td width="100%">
				<xsl:for-each select="tags/tag">
				<xsl:sort select="."/>
				<font face="Arial" size="2">
				<xsl:element name ="a">
					<xsl:attribute name="href">videodb.html?tag=<xsl:value-of select="."/>
					</xsl:attribute>
					<font color="0066cc">
					<xsl:value-of select="."/>
					</font>
				</xsl:element>
				</font>

			</xsl:for-each>
			</td>
			</tr>
			
		</tbody>
	</table>	
	</xsl:for-each>
	</xsl:if>
	</xsl:for-each>

</body>
</html>
</xsl:template>
</xsl:stylesheet>

Reply With Quote
  #2  
Old June 15th, 2009, 10:19 AM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Novice (500 - 999 posts)
 
Join Date: Sep 2004
Posts: 576 jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level)jkmyoung User rank is Sergeant Major (2000 - 5000 Reputation Level) 
Time spent in forums: 2 Weeks 4 Days 3 h 58 m 24 sec
Reputation Power: 55
First of all, you'd have to pass in a date. Either the current date, or the date for 30 days ago. It's easier for xslt if you pass in the date 30 days ago, since xslt is not very good for numeric computation.
Due to the layout of your xslt, it'd be even better if you passed in the year, month and day seperately.
<xsl:param name="year"/>
<xsl:param name="month"/>
<xsl:param name="day"/>

When you say only show the files that have been added, do you mean still show the videos, but not the older files, or not show the videos entirely? Do you ever have multiple files to a video?

Assuming 1 file to a video, and not showing the entire video, and further assuming a d/m/yyyy layout to your date:
Code:
<xsl:for-each select="catalog/video"> 
<xsl:sort select="file/name"/>
    <xsl:variable name="vday" select="substring-before(file/added,'/')"/>
    <xsl:variable name="vmonth" select="substring-before(substring-after(file/added,'/'),'/')"/>
    <xsl:variable name="vyear" select="substring(substring-after(substring-after(file/added,'/'),'/'),1,4)"/>
    <xsl:if test="(vyear > $year) or 
  ((vyear = $year) and
   (vmonth > $month)) or
  ((vyear = $year) and
   (vmonth = $month) and
   (vday >= $day))">
     ...what you already have goes here...

</xsl:if>

Reply With Quote
  #3  
Old June 15th, 2009, 12:25 PM
ignignokt ignignokt is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 47 ignignokt User rank is Lance Corporal (50 - 100 Reputation Level)ignignokt User rank is Lance Corporal (50 - 100 Reputation Level)ignignokt User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 23 h 26 m 9 sec
Reputation Power: 4
jkmyoung, thanks for the reply and help.

The XML creates 1 file to a video. So, when a link is clicked on the main HTML page (What's New), I want to filter the entire XML file and only show the videos which have an added date of 30 days or less.

Ill give this a try and let you know the results.

Reply With Quote
  #4  
Old June 17th, 2009, 09:12 AM
ignignokt ignignokt is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2006
Posts: 47 ignignokt User rank is Lance Corporal (50 - 100 Reputation Level)ignignokt User rank is Lance Corporal (50 - 100 Reputation Level)ignignokt User rank is Lance Corporal (50 - 100 Reputation Level) 
Time spent in forums: 23 h 26 m 9 sec
Reputation Power: 4
Resolved!

jkmyoung,

There WAS an issue with my Javascript and I resolved it. Its working perfectly. Thanks for your help. I just have to work on finding a date 30 days in the past with JS.

Thanks again.

Last edited by ignignokt : June 17th, 2009 at 11:44 AM. Reason: Resolved

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > Showing Records Within Last 30 Days


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump




 Free IT White Papers!
 
How to Present Effectively Online
This white paper offers practical and actionable advice on the key steps that any presenter should consider as they plan and execute a Webinar or online meeting.

 
Open Source Security Myths
Open Source Software (OSS) is computer software whose source code is available to the general public with relaxed or non-existent intellectual property restrictions (or arrangement such as the public domain), and is usually developed with the input of many contributors.

 
Power and Cooling Capacity Management for Data Centers
This paper describes the principles for achieving power and cooling capacity management.

 
Scalable, Fault-Tolerant NAS for Oracle - The Next Generation
For several years NAS has been evolving as a storage alternative for Oracle databases, and for good reason: NAS is quite often the simplest, most cost-effective storage approach for Oracle. Learn about the benefits that HP's approach to scalable NAS brings to Oracle environments in this comprehensive white paper.

 
Understanding Web Application Security Challenges
This white paper discusses many common threats and preventive measures for Web application security, and explains what you can do to help protect your organization.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 




© 2003-2009 by Developer Shed. All rights reserved. DS Cluster 4 Hosted by Hostway
Stay green...Green IT