Skip to content

Sort XML by date using xslt

For this, we just use the simple xml. <?xml version="1.0" encoding="utf-8"?> <?xml-stylesheet type="text/xsl" href="style.xslt"?> <birthdays> <item> <date>13.05.2005</date> <title>John</title> </item> <item> <date>06.02.2000</date> <title>Steve</title> </item> <item> <date>13.01.2007</date> <title>Lisa</title> </item> <item> <date>29.05.2010</date> <title>Sarah</title> </item> </birthdays> And the xslt code would be something like this <?xml version="1.0" encoding="utf-8"?> <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="birthdays"> <h1>Birthdays</h1> <ul> <xsl:for-each select="item"> <xsl:sort select="normalize-space(substring(date,7,4))" order="descending" /> <xsl:sort select="normalize-space(substring(date,4,2))" order="descending" /> <xsl:sort select="normalize-space(substring(date,0,2))" order="descending" /> <li> <xsl:value-of select="date" /> <br /> <xsl:value-of select="title" /> </li> </xsl:for-each> </ul> </xsl:template> </xsl:stylesheet> Output Birthdays 29.05.2010 Sarah 13.01.2007 Lisa 13.05.2005 John 06.02.2000 Steve Advertisements

Read More →

How to access a variable from within xsl:for-each from outside xsl:for-each

You must have used variables in xslt, like how easy it is to use them anywhere. In the same way you can also wrap xsl: for-each with an xsl: variable. For example, the following stylesheet declares a variable EmployeeName and within the xsl: for-each it uses xsl: value-of and xsl: text. All of the text values are assigned to the variable EmployeeName, which […]

Read More →

Javascript Back Button

Just like your browser’s back button, the following script allows the user to press a button to returns the user to the previous page. Paste the following code where you want the button to appear on your page:  <FORM> <INPUT TYPE=”Button” VALUE=”Previous Page” onClick=”history.go(-1)”> </FORM> If you would rather use a link, paste the following code where you want the link to appear:  <a href=”javascript:history.back(1)”>Previous Page</a>

Read More →

SQL Query to get modified procedures

SQL Query You can use a simple query in sql server 2005 to get the modified procedures from a particular date. You just need to specify the date in the query. Try it out !!! SELECT name , modify_date FROM sys.objects WHERE type = ‘P’ AND modify_date >= ‘2011-11-24’ order by name In the same way, you can retreive the modified tables also SELECT name , modify_date FROM sys.objects WHERE type = ‘U’ AND modify_date >= ‘2011-11-24’ order by name

Read More →