Recent Notes

Displaying keyword search results 1 - 10
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 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 Fang on August 24, 2010 18:44:24    Last update: August 24, 2010 18:44:24
The tags XML transform tags apply XSLT to XML documents. The XML document may be specified as the doc attribute or enclosed as the body of the <x:transform> tag. Optional <x:param> tags may be used to specify parameters for the XSLT. <x:transform> Syntax: <x:transform doc="XMLDocument" xslt="XSLTStyle... or, include the XML document in the body: <x:transform xslt="XSLTStylesheet" [docSystem... Attributes: Name Dynamic? Type Description doc true String , Reader , javax.xml.transform.Source , org.w3c.dom.Document , or object exported by <x:parse> , <x:set> . Source XML document to be transformed. (If exported by <x:set> , it must correspond to a well-formed XML document, not a partial document.) xslt true String , Reader or javax.xml.transform.Source Transformation stylesheet as a String , Reader , or Source object. docSystemId true...
Created by Fang on August 23, 2010 22:55:58    Last update: August 24, 2010 15:45:04
The tags XML flow control tags are exactly the same as their Core flow control equivalents, except that the test condition with a boolean EL expression is replaced by the select condition with an XPath expression. In the case of the forEach tag, the items attribute is replaced with the select attribute. In a test condition, the XPath expression is evaluated to a boolean value by the rules of the XPath boolean() function, which converts its argument to a boolean as follows: a number is true if and only if it is neither positive or negative zero nor NaN. a node-set is true if and only if it is non-empty. a string is true if and only if its length is non-zero. an object of...
Created by Fang on August 19, 2010 18:32:28    Last update: August 19, 2010 18:32:28
The tags <x:parse> Parses an XML document. The document to be parsed can be specified by the doc attribute or enclosed as the body of the tag. The parsed document is exposed as the var attribute or the varDom attribute. When exposed as var , the type of the exposed object is implementation dependent; when exposed as varDom , the type of the exposed object is org.w3c.dom.Document . Objects exposed by var and varDom can both be used to set the context of an XPath expression. Syntax: <x:parse doc="XMLDocument" {var="var" [sco... or, put the XML document in the element body: <x:parse {var="var" [scope="page|request|s... Attributes: Name Dynamic? Type Description doc true String , Reader Source XML document to be parsed. systemId true String The...
Created by Fang on August 18, 2010 20:07:46    Last update: August 18, 2010 20:11:36
JSTL uses XPath expressions as a concise notation to specify or select parts of an XML document. JSTL provides EL like expressions to access web application data and comes with the core function library of the XPath specification. Accessing Web Application Data XPath Expression Mapping $foo pageContext.findAttribute("foo") $param:foo request.getParameter("foo") $header:foo request.getHeader("foo") $cookie:foo maps to the cookie's value for name foo $initParam:foo application.getInitParameter("foo") $pageScope:foo pageContext.getAttribute("foo", PageContext.PAGE_SCOPE) $requestScope:foo pageContext.getAttribute("foo", PageContext.REQUEST_SCOPE) $sessionScope:foo pageContext.getAttribute("foo", PageContext.SESSION_SCOPE) $applicationScope:foo pageContext.getAttribute("foo", PageContext.APPLICATION_SCOPE) For example, to find the bar element whose x attribute equals the value of the HTTP request parameter named paramName : /foo/bar[@x=$param:paramName] Java Type to XPath Type Mappings XPath Type Java Type java.lang.Boolean boolean java.lang.Number number java.lang.String string Object exported by <x:parse> node-set Please note that JSTL, as of version 1.2,...
Created by Fang on July 26, 2010 19:18:28    Last update: August 18, 2010 19:13:02
The tags <c:import> The <c:import> tag imports the contents of a URL and expose that in one of three ways: Import contents from a URL and write it out to the page (url may be relative or absolute): <c:import url="theUrl" /> Import contents from a URL and save it to a scoped variable string named by the var attribute. Use the scope attribute to define the scope of the exported variable. <c:import url="theUrl" var="importTest" scope="ses... Import a URL and expose to a Reader object named by the varReader attribute. The scope attribute does not apply. The varReader scoped variable can only be accessed within the body of <c:import> . <c:import url="theUrl" varReader="theReader"/> <c:url> The <c:url> tag constructs a URL and writes it out to the...
Previous  1 2 Next