[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] Xpath patern question


Subject: [xsl] Xpath patern question
From: Hélder Sousa <Helder.Sousa@xxxxxx>
Date: Mon, 10 Mar 2003 16:16:08 -0000

Hi!

I have the follow xml example:
<?xml version="1.0" encoding="UTF-8"?>
<xxx>
	<yyyy>
		<campo>12-12-2002</campo>
		<campo>2</campo>
	</yyyy>
	<zzz>
		<campo>1</campo>
		<campo>2</campo>
	</zzz>
</xxx>

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! 
I'm doing that using javascript in xsl
<xsl:script>
	<![CDATA[
	function VerifyDate( node ){
	   var node_Value = node.selectSingleNode(".");
	   var value = new String( node_Value.text );
	   var encont = value.match(/(\d{1,2})[-|\/](\d{1,2})[-||\/](\d{4})/);
	   if ( encont != null )
	     return true;
	   else
	     return false;
	}
	]]>
</xsl:script>

My question is: "This is possible to do with xpath, without using the script?" Tks for helpe.




Hélder Sousa
Departamento de  Projectos e-Business 
I2S - Informática Sistemas e Serviços 
<<mailto:helder.sousa@xxxxxx>> - <<http://www.i2s.pt/>>
Tel.: +351 22 834 04 00; Fax: +351 22 834 07 95 
Portugal 

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



Current Thread
Keywords