xsl-list
[Top] [All Lists]

Xpath patern question

2003-03-10 09:16:08
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(_dot_)sousa(_at_)i2s(_dot_)pt>> - <<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



<Prev in Thread] Current Thread [Next in Thread>