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

RE: Xpath patern question

Subject: RE: Xpath patern question
From: Hélder Sousa <Helder.Sousa@xxxxxx>
Date: Mon, 10 Mar 2003 17:34:37 -0000
helder sousa
I had think about that solution but my date can be like "1/1/2003" and I can't change it to " 1/ 1/2003".. So that doesn't work. I can put some more conditions in [...] but in this case it's better to use the script..
The regular expression would be the best way..
Tks anyway :)


-----Original Message-----
From: Jeni Tennison [mailto:jeni@xxxxxxxxxxxxxxxx] 
Sent: segunda-feira, 10 de Março de 2003 17:19
To: Hélder Sousa
Cc: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Xpath patern question


Hi Hélder,

> Imagine that I want all elements "campo" with value matching a 
> determinate patern. For example, I want all elements "campo" whose 
> value is like "2 digits, a separator("/" or "-"), 2 digits, a 
> separator("/" or "-"), 4 digits". This is a date!

Try something like:

  /xxx/yyyy/campo[number(substring(., 1, 2)) and
                  (substring(., 2, 1) = '/' or
                   substring(., 2, 1) = '-') and
                  number(substring(., 4, 2)) and
                  (substring(., 2, 1) = '/' or
                   substring(., 2, 1) = '-') and
                  number(substring(., 7, 4))]

This will allow things like " 3/ 7/   4", which you might not want;
you could disallow them by adding a "not(contains(., ' '))" clause.

Note that XPath 2.0 will allow you to use a regular expression here, so you will be able to do:

  /xxx/yyyy/campo[matches(., '\d{2}[-/]\d{2}[-/]\d{4}')]

Cheers,

Jeni

---
Jeni Tennison
http://www.jenitennison.com/


 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


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-2013 All Rights Reserved.