You are viewing a plain text version of this content. The canonical link for it is here.
Posted to fop-users@xmlgraphics.apache.org by Jasmin Mehta <jm...@mdnotes.com> on 2003/03/27 17:00:35 UTC
xsl question about substring/index
Hi,
Can anybody please tell me how to get indexes of specific strings?
For example, I have a long date tag in XML
<submitdate>Monday, March 24, 2003 4:02:03 PM EST</submitdate>
And I just want to display 'Monday, March 24, 2003' in my PDF file using
xsl-fo.
It I have to substring it in Java, I would have written
String targetStr =
submitdate.substring(0,submitdate.lastIndexOf(',')+4);
How can I get similar function xsl? I saw substring-after() and
substring-after() function on some site. But it doesn't seems to give me
the result I want.
Thanks
Jasmin
Re: xsl question about substring/index
Posted by "J.Pietschmann" <j3...@yahoo.de>.
Jasmin Mehta wrote:
> <submitdate>Monday, March 24, 2003 4:02:03 PM EST</submitdate>
You should try to get ISO date format in the source, it makes
processing *much* easier.
Apart from this this is a XSLT FAQ:
http://www.dpawson.co.uk/
http://www.mulberrytech.com/xsl/xsl-list/
J.Pietschmann
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: xsl question about substring/index
Posted by Jeremias Maerki <de...@greenmail.ch>.
As a quick hack you could write a simple Java class and plug it into
Xalan. It is very easy, but isn't portable (Xalan-specific). As a
template:
package com.mdnotes.xalanext;
public class MyXalanExtension {
public String truncateMyDateFormat(String theDate) {
return theDate.substring........
}
}
In you stylesheet:
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:myext="com.mdnotes.xalanext.MyXalanExtension"
extension-element-prefixes="myext">
[..]
<xsl:value-of select="myext:truncateMyDateFormat(element/@date)"/>
More information here: http://xml.apache.org/xalan-j/extensions.html
On 27.03.2003 19:12:43 Jasmin Mehta wrote:
> The links you have mentioned has excellent source for date time
> functions. But I am receiving a date in XML file that has not matching
> format according to XML Schema Part 2: Datatypes. So I can not use that
> function.
>
> So I am now looking for some string function only that can give me the
> format I want.
>
> Can you help on this? Its not immediate requirement, but it would be
> great If I can figure out something in couple hours.
Jeremias Maerki
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: xsl question about substring/index
Posted by Clay Leeds <cl...@medata.com>.
Jasmin,
Here's a page with some "date" extensions to XSLT:
http://www.exslt.org/date
Here's a differen extension worth checking out:
http://xsltsl.sourceforge.net/date-time.html
I'm sure there's an XSL template out there somewhere that does exactly
what you're looking for, but I couldn't find it in 5 mins of looking...
sorry.
Jasmin Mehta wrote:
> Hi,
>
> Can anybody please tell me how to get indexes of specific strings?
>
> For example, I have a long date tag in XML
>
> <submitdate>Monday, March 24, 2003 4:02:03 PM EST</submitdate>
>
> And I just want to display ‘Monday, March 24, 2003’ in my PDF file using
> xsl-fo.
>
> It I have to substring it in Java, I would have written
>
> String targetStr = submitdate.substring(0,submitdate.lastIndexOf(‘,’)+4);
>
> How can I get similar function xsl? I saw substring-after() and
> substring-after() function on some site. But it doesn’t seems to give me
> the result I want.
>
> Thanks
>
> Jasmin
--
Clay Leeds - cleeds@medata.com
Web Developer - Medata, Inc. - http://www.medata.com
PGP Public Key: https://mail.medata.com/pgp/cleeds.asc
---------------------------------------------------------------------
To unsubscribe, e-mail: fop-user-unsubscribe@xml.apache.org
For additional commands, e-mail: fop-user-help@xml.apache.org
Re: xsl question about substring/index
Posted by Narinder Garg <na...@yahoo.com>.
Hi,
try this
<xsl:value-of select="substring-before(.,',')" />,<xsl:value-of select="substring-before(substring-after(.,','),',')" />,<xsl:value-of select="substring(substring-after(substring-after(.,','),','),1,5)" />
take care
narinder
Jasmin Mehta <jm...@mdnotes.com> wrote:
st1\:*{behavior:url(#default#ieooui) }
Hi,
Can anybody please tell me how to get indexes of specific strings?
For example, I have a long date tag in XML
<submitdate>Monday, March 24, 2003 4:02:03 PM EST</submitdate>
And I just want to display �Monday, March 24, 2003� in my PDF file using xsl-fo.
It I have to substring it in Java, I would have written
String targetStr = submitdate.substring(0,submitdate.lastIndexOf(�,�)+4);
How can I get similar function xsl? I saw substring-after() and substring-after() function on some site. But it doesn�t seems to give me the result I want.
Thanks
Jasmin
---------------------------------
Do you Yahoo!?
Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop!