W3C home > Mailing lists > Public > www-xsl-fo@w3.org > November 2008

Re: Regular Expression's Jungle

From: sonika_nitj <sonika.janagill@patni.com>
Date: Thu, 6 Nov 2008 22:34:32 -0800 (PST)
Message-ID: <20375430.post@talk.nabble.com>
To: www-xsl-fo@w3.org


Hi...
I have also faced same problem.
See what I have used for formatting a date from one format to other:
<fo:inline>
        <xsl:variable name="formattedIssueDate" 
select="java:parse(java:java.text.SimpleDateFormat.new('yyyy-MM-dd
HH:mm:ss.SSS' ), //IssueDate)" />
	<xsl:value-of
select="java:format(java:java.text.SimpleDateFormat.new('MM/dd/yyyy' ),
$formattedIssueDate)" />
</fo:inline>

What you have to do is the following:
        <xsl:variable name="formattedIssueDate" 
select="java:parse(java:java.text.SimpleDateFormat.new('MM/dd/yyyy' ),
//IssueDate)" />
	<xsl:value-of
select="java:format(java:java.text.SimpleDateFormat.new('MM-dd-yyyy' ),
$formattedIssueDate)" />

Note that the Date format you provide in SimpleDateFormat constructor should
be a proper date format.
And the java namespace should be added to your style sheet
 as follows:
<xsl:stylesheet version="1.1"
	xmlns:java="http://xml.apache.org/xslt/java"
	exclude-result-prefixes="java"
	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
	xmlns:fo="http://www.w3.org/1999/XSL/Format">

-Sonika

saqi wrote:
> 
> Hello,
> I want to add some regular expression; when i get some data in any other
> format just convert it to my own. like if i have a date like 02/23/2008
> then
> convert it to 02-23-2008. i have surfed the web but cannot find any simple
> example that can fit in. I found many complex examples all the way, which
> just passed over me...lolz. Is there any simple example available or help
> through which i can understand the basic working of regex, and can define
> my
> own regular expressions.
> Thanks
> Regards,
> Saqib Javed
> 
> 

-- 
View this message in context: http://www.nabble.com/Regular-Expression%27s-Jungle-tp20375265p20375430.html
Sent from the w3.org - www-xsl-fo mailing list archive at Nabble.com.
Received on Friday, 7 November 2008 06:35:38 GMT

This archive was generated by hypermail 2.2.0+W3C-0.50 : Friday, 7 November 2008 06:35:39 GMT