[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: identifying series of numbers in text strings

Subject: Re: identifying series of numbers in text strings
From: "Dimitre Novatchev" <dnovatchev@xxxxxxxxx>
Date: Sun, 27 Jul 2008 11:47:11 -0700
Re:  identifying series of numbers in text strings
> Do you use an XSLT 1.0 processor that supports EXSLT? Then you could use http://www.exslt.org/regexp/functions/match/index.html.
> Firefox 3.0 has support for that match function. With IE and MSXML you can use the implementation provided at the exslt.org site.
>



EXSLT is not really needed:

<xsl:stylesheet version="1.0"
 xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

	<xsl:template match="date">
	  <xsl:variable name="vUnits" select=
	   "translate(., '0123456789', '1111111111')"
	   />
	 <xsl:value-of select=
	  "contains(substring-after($vUnits, '1111'), '1111')"
	  />
	</xsl:template>
</xsl:stylesheet>

Applied on this xml document:

<t>
	<date>23 July 2001-April 2006</date>
	<date>July 1996</date>
	<date>unknown</date>
</t>

The result is:

<?xml version="1.0" encoding="utf-8"?>
	true
	false
	false



--
Cheers,
Dimitre Novatchev
---------------------------------------
Truly great madness cannot be achieved without significant intelligence.
---------------------------------------
To invent, you need a good imagination and a pile of junk
-------------------------------------
Never fight an inanimate object
-------------------------------------
You've achieved success in your field when you don't know whether what
you're doing is work or play




On Sun, Jul 27, 2008 at 10:01 AM, Martin Honnen <Martin.Honnen@xxxxxx> wrote:
>
> Joyce Celeste Chapman wrote:
>
>> Using XSL 1.0, is there a way I can search the contents of an element to find series of 4-digit numbers? Then if there are two sets of 4-digit numbers, I would like to select those values in order (I'll be outputting them somewhere else as a date span), if there is only one 4-digit set I'll need to output that a different way. Example of XML below. Thanks to all in advance for the help!
>>
>> <date>23 July 2001-April 2006</date>
>> <date>July 1996</date>
>> <date>unknown</date>
>
> Do you use an XSLT 1.0 processor that supports EXSLT? Then you could use http://www.exslt.org/regexp/functions/match/index.html.
> Firefox 3.0 has support for that match function. With IE and MSXML you can use the implementation provided at the exslt.org site.
>
>
> --
>
>        Martin Honnen
>        http://JavaScript.FAQTs.com/

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.