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
  #1  
Old April 14th, 2008, 05:58 AM
stevanicus stevanicus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 18 stevanicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 33 sec
Reputation Power: 0
XSL date

Hi there,

is it possible to show a certain part of an xml date with xsl?

ie.
Code:
<MONDAY>
<TASK>GO TO DOCTORS</TASK>
</MONDAY>
<TUESDAY>
<TASK>WALK THE DOG</TASK>
</TUESDAY>


xsl.
Code:
if tuesday... show - task (walk the dog)

could anyone give me a small code snippet, so i get the jist of it.

Thanks

Steve

Reply With Quote
  #2  
Old April 14th, 2008, 07:44 AM
atlantisstorm atlantisstorm is offline
Hang your freedom higher.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 14 m 2 sec
Reputation Power: 113
If you have XML roughly like this...
Code:
<WRAPPER>
	<DAYOFWEEK>TUESDAY</DAYOFWEEK>
...
	<MONDAY>
		<TASK>GO TO DOCTORS</TASK>
	</MONDAY>
	<TUESDAY>
		<TASK>WALK THE DOG</TASK>
	</TUESDAY>
</WRAPPER>


Then you could use the following XSL (untested)
Code:
...
<td> Your task today is 
                                        <xsl:choose>
                                          <xsl:when test="/WRAPPER/DAYOFWEEK = 'MONDAY'">
                                            <xsl:value-of select='/WRAPPER/MONDAY/TASK'/>
                                          </xsl:when>
                                          ...
                                          <xsl:when test="/WRAPPER/DAYOFWEEK = 'SUNDAY'">
                                            <xsl:value-of select='/WRAPPER/SUNDAY/TASK'/>
                                          </xsl:when>
                                        </xsl:choose>
</td>
...
__________________
"Badges? We ain't got no badges. We don't need to badges! I don't have to show you any stinkin' badges!!"

Reply With Quote
  #3  
Old April 14th, 2008, 09:11 AM
stevanicus stevanicus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 18 stevanicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 33 sec
Reputation Power: 0
Thanks,

but how will it know when it is monday? just to show monday?

steve

Reply With Quote
  #4  
Old April 14th, 2008, 02:44 PM
atlantisstorm atlantisstorm is offline
Hang your freedom higher.
Dev Shed Novice (500 - 999 posts)
 
Join Date: Jan 2005
Posts: 600 atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level)atlantisstorm User rank is First Lieutenant (10000 - 20000 Reputation Level) 
Time spent in forums: 1 Week 6 Days 10 h 14 m 2 sec
Reputation Power: 113
Quote:
Originally Posted by stevanicus
Thanks,

but how will it know when it is monday? just to show monday?

steve

You need to supply that information in the XML ...

Code:
<WRAPPER>
<DAYOFWEEK>TUESDAY</DAYOFWEEK>
...

Reply With Quote
  #5  
Old April 14th, 2008, 05:28 PM
stevanicus stevanicus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 18 stevanicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 33 sec
Reputation Power: 0
heya,

thanks for your help... but i dont get it haha.

I have an xml with mulitple 'tasks' for each day of the week. and i would like to only display the tasks for the current day.

thanks again

steve

Reply With Quote
  #6  
Old April 14th, 2008, 05:31 PM
stevanicus stevanicus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 18 stevanicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 33 sec
Reputation Power: 0
this is how far i got so far

xml
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<WRAP>
<DOW>
<DAY>1</DAY>
<TASK>Doctors</TASK>
<DAY>TWO</DAY>
<TASK>Walk the Dog</TASK>
</DOW>
<DOW>
<DAY>2</DAY>
<TASK>Doctors</TASK>
<DAY>TWO</DAY>
<TASK>Walk the Dog</TASK>
</DOW>
</WRAP>


xsl
Code:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
  <html>

  <body>
	<table>
      <xsl:for-each select="WRAP/DOW">
	<xsl:choose>
          <xsl:when test="DAY = '1'">
          <xsl:value-of select='TASK'/>
          </xsl:when>
        </xsl:choose>
      </xsl:for-each>
	</table>
  </body>
  </html>
</xsl:template>

</xsl:stylesheet>


but where

Code:
<xsl:when test="DAY = '1'">


im trying(only way i know) is to do something like this

Code:
<script>
var current_date = new Date();
var today = current_date.getDay();
</script>
...
<xsl:when test="DAY = today">


thanks

steve

Reply With Quote
  #7  
Old April 15th, 2008, 01:11 PM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 474 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: 3 Days 18 m 31 sec
Reputation Power: 52
Whatever you're using to process the XSLT should have the date in it. PHP? C#?
If you're processing the XML directly linking to the XSLT with a processing instruction, then you'd have to use either a javascript or XSLT 2.0 solution.

eg fn:current-dateTime()
http://www.w3schools.com/xpath/xpath_functions.asp#datetime

Reply With Quote
  #8  
Old April 17th, 2008, 06:53 PM
stevanicus stevanicus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 18 stevanicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 33 sec
Reputation Power: 0
heya,

thanks for your info...

i managed to get the following. but stuck with makeing the today variable global inorder to use it in my <when test>

Code:
<?xml version="1.0" encoding="iso-8859-1"?>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
  <html>
  <body>
  <link media="all" rel="stylesheet" type="text/css" href="thecss.css" />
    <script language="JavaScript">
      var cDate = new Date();
      var today = cDate.getDay();
      <xsl:variable name="tday">today</xsl:variable>
      alert(<xsl:value-of select='$tday' />);
    </script>
  <div class="stitle">Schedule</div>
  <xsl:for-each select="SCHEDULE/DOW">
    <xsl:choose>
    <xsl:when test="DAY = $tday"> <!-- tday out of scope -->
      <div class="date">
        <xsl:value-of select="DATE" />
      </div>
      <div class="schedule">
      <xsl:for-each select="SHOW">
      <div>
        <div class="stime">
          <xsl:value-of select="STIME" /> -
        </div>
        <div class="etime">
          <xsl:value-of select="ETIME" />
        </div>
        <div class="title">
          <xsl:value-of select="TITLE" />
        </div>
        <div class="description">
          <xsl:value-of select="DESCRIPTION" />
        </div>
      <br />
      </div>
      </xsl:for-each>
      </div>
    </xsl:when>
    </xsl:choose>
    </xsl:for-each>
  </body>
  </html>
</xsl:template>
</xsl:stylesheet>


any ideas?

thanks

steve

Reply With Quote
  #9  
Old April 19th, 2008, 12:26 AM
Captain Sigma Captain Sigma is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 7 Captain Sigma User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 22 m 22 sec
Reputation Power: 0
I needed that also, thanks.

Reply With Quote
  #10  
Old April 19th, 2008, 10:48 AM
jkmyoung jkmyoung is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2004
Posts: 474 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: 3 Days 18 m 31 sec
Reputation Power: 52
As stated in the other forum
<xsl:variable name="tday">today</xsl:variable>
Will give you a variable of string today. It will not provide the javascript variable value.

Reply With Quote
  #11  
Old April 19th, 2008, 10:54 AM
stevanicus stevanicus is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2008
Posts: 18 stevanicus User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 29 m 33 sec
Reputation Power: 0
Quote:
Originally Posted by jkmyoung
As stated in the other forum
<xsl:variable name="tday">today</xsl:variable>
Will give you a variable of string today. It will not provide the javascript variable value.


it does work for me,
when the alert function calls the value of tday.. it prints a number (day of the week)

But how can i make that a global variable?

thanks

steve

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreXML Programming > XSL date


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!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

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