Recent Notes

Displaying keyword search results 1 - 10
Created by James on November 27, 2011 12:43:24    Last update: November 27, 2011 12:59:01
An easy to digest stylesheet example for XSLT for Atom. Simply list entry titles and summary: <?xml version="1.0" encoding="utf-8"?> <xsl:sty... To show the first 3 items in atom feed: <?xml version="1.0" encoding="utf-8"?> <xsl:sty...
Created by James on November 23, 2011 13:57:51    Last update: November 23, 2011 13:57:51
An easy to digest stylesheet example for XSLT for RSS. Simply list item titles descriptions: <?xml version="1.0" encoding="utf-8"?> <xsl:sty... URL for Google news feed: http://news.google.com/news?ned=us&topic=h&output=rss
Created by nogeek on November 03, 2010 20:52:49    Last update: November 23, 2011 08:54:44
My problem is simple: in my XML data, a timestamp is provided as a long integer (number of milliseconds since the "the epoch"). When I do XSLT, I want to display it as a readable string, such as "Mon Nov 01 18:08:48 CDT 2010". After hours of struggle, I found: It's not so easy to get the job done with JDK 1.6 There are tons of garbage on the web in this space (suggestions, code snippets that simply don't work) Simple Xalan extension functions was the only resource that's somewhat informative. Even there some of the examples don't work. Below is a list of what worked and what didn't. This works: <xsl:stylesheet version="1.0" xmlns:xsl="h... This does not (providing long value to Date constructor): <xsl:stylesheet version="1.0" xmlns:xsl="h......
Created by Fang on November 10, 2011 09:26:12    Last update: November 10, 2011 09:26:12
Syntax highlighted XML schema for JSF 2.0 Application Configuration Resource File ( faces-config.xml ). Almost 3000 lines! <?xml version="1.0" encoding="UTF-8"?> <xsd:sch...
Created by nogeek on November 11, 2010 00:26:08    Last update: November 11, 2010 00:29:43
This one is even more weird: it worked on Windows but failed on Linux, using default tools JDK1.6.0_20 on both. The exception thrown was: java.lang.RuntimeException: Invalid conversion fro... And the stack trace: java.lang.RuntimeException: Invalid conversion fro... This was the XSL used: <?xml version="1.0" encoding="ISO-8859-1"?> <xs... The problem was , DateUtil.java had two getDate methods, one taking long parameter, the other taking a String parameter. And Java's XSLT get confused about which one to use: import java.util.Date; import java.text.SimpleD...
Created by nogeek on November 04, 2010 20:00:15    Last update: November 05, 2010 14:38:43
Following are some bugs in the Xalan jar shipped with JBoss 5.1.0 GA and JBoss 6.0. The Xalan jar file is located in jboss-5.1.0.GA/lib/endorsed ( %JBOSS_HOME%/common/lib for JBoss 6.0). Test xml: <?xml version="1.0" encoding="ISO-8859-1"?> ... Test xsl: <?xml version="1.0" encoding="ISO-8859-1"?> <xs... XSLT Java code: import org.w3c.dom.*; import javax.xml.parsers.... DateUtil.java import java.util.Date; public class DateUti... XSLT output: Transformer Factory class: class org.apache.xalan.... Apparently, the output is wrong. The string "A test event" should not have been displayed.
Created by nogeek on November 04, 2010 20:55:31    Last update: November 05, 2010 14:36:09
Following part 1 , change to stylesheet to: <?xml version="1.0" encoding="ISO-8859-1"?> <xs... The XSLT output becomes: java Xslt test.xml test.xsl Transformer Fac... Parameter is not passed! The Xalan version that comes with JDK 1.6 processed this correctly: java -Djavax.xml.transform.TransformerFactory=com....
Created by nogeek on November 04, 2010 23:25:57    Last update: November 04, 2010 23:26:59
With this XML file: <?xml version="1.0" encoding="ISO-8859-1"?> <ev... and this XSL: <?xml version="1.0" encoding="ISO-8859-1"?> <xs... The output of XSLT is: A test event Timestamp: 12886515008... You may not want the title string in the output. There are two ways to do this: Limit the apply-templates action with a select attribute: <xsl:template match="/"> <xsl:apply-templat... Suppress default text node output with an empty template: <?xml version="1.0" encoding="ISO-8859-1"?> <xs... Reference: http://www.dpawson.co.uk/xsl/sect2/defaultrule.html
Created by nogeek on November 04, 2010 20:08:02    Last update: November 04, 2010 20:45:25
Use the <xsl:with-param> and <xsl:param> tags to apply parameters to XSL stylesheets: <?xml version="1.0" encoding="ISO-8859-1"?> <xs...
Created by nogeek on November 04, 2010 20:24:32    Last update: November 04, 2010 20:24:55
XSLT by default writes namespace declarations in the output. Most of the time it's spurious, sometimes outright wrong. Take this XML: <?xml version="1.0" encoding="ISO-8859-1"?> <ev... And this XSL: <?xml version="1.0" encoding="ISO-8859-1"?> <xs... where DateUtil.java is: import java.util.Date; public class DateUti... The output is (with JDK1.6): Title: <br xmlns:java="http://xml.apache.org/x... The namespace declaration went to the <br> element, not the timestamp where it belongs. To remove the namespace info, add exclude-result-prefixes to the XSL: <?xml version="1.0" encoding="ISO-8859-1"?> <xs...
Previous  1 2 Next