With XSLT 2.0 a method is provided, which splits a string by a specific delimiter (e.g. commas, spaces or other) quite easily.
This function returns the part of $arg which appears before the last occurrence of $delim. If $arg does not contain $delim, a zero-length string is returned.
If you split the string “XPath-is-fun” as $arg with $delim “-” you will get the following result:
Unfortunately, this function is not provided in XSLT 1.0. But there is a possibility of realizing this without any 3rd party libraries (e.g. EXSLT). The following example shows, how this can be done with XSLT 1.0.
With XSLT 2.0 a method is provided, which tokenizes a string by a specific delimiter (e.q. commas, spaces or other) quite easily.
<xsl:variable name="stringList" select="tokenize('XPath is fun', ' ')"/>
This subsequently can be used to iterate over the individual String elements:
<xsl:value-of select="." />
The result of this easy method call is tokenized by spaces, so we get:
"XPath", "is", "fun"
Unfortunately, this function is not provided in XSLT 1.0, but there is the possibility of realizing this without any 3rd party libraries (e.q. EXSLT). The following example shows, how this can be done with XSLT 1.0.
With XSLT 2.0, a method is provided, which quite simply determines the current date or time.
Recently I had the problem of validating XHTML file using DTD schema and Java. As for DTD validation to find little on the Internet, I would like to explain briefly how this is possible by simply using Java resources.
The following examples show, how a date, calendar or formatted String can be converted into XMLGregorianCalendar object.
In some circumstance it is neccessary to get a sorted List of files from folder. Therefore the Java API provides some functions to access the local file system. The following snippets will demonstrate how the identified files can be sorted useful: