|
Subject: Re: [xsl] Xpath patern question From: Jeni Tennison <jeni@xxxxxxxxxxxxxxxx> Date: Mon, 10 Mar 2003 17:19:28 +0000 |
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 |
|---|
|
| <- Previous | Index | Next -> |
|---|---|---|
| [xsl] Xpath patern question, Hélder Sousa | Thread | RE: [xsl] Xpath patern question, Hélder Sousa |
| [xsl] How to filter nodes on attrib, Ankit Jain | Date | Re: [xsl] trying to create a node-s, Jeni Tennison |
| Month |