Changeset 1999

Show
Ignore:
Timestamp:
10/03/06 22:46:51
Author:
miyagawa
Message:

fixed handling of :not pseudo-class to work on XPath 1.0 implementation. This be 0.02

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • HTML-Selector-XPath/trunk/Changes

    r1991 r1999  
    11Revision history for Perl extension HTML::Selector::XPath 
     2 
     3  0.02  Tue Oct  3 22:43:39 JST 2006 
     4        * Added support for :not() without XPath 2.0 
     5          (Thanks to Aristotle Pegaltzis) 
    26 
    37  0.01  Sun Sep 24 20:10:35 2006 
  • HTML-Selector-XPath/trunk/lib/HTML/Selector/XPath.pm

    r1998 r1999  
    22 
    33use strict; 
    4 our $VERSION = '0.01'; 
     4our $VERSION = '0.02'; 
    55 
    66require Exporter; 
     
    9999                    push @parts, "[\@$1!='$3']"; 
    100100                } elsif ($2 eq '~=') { 
    101                     push @parts, ":not([contains(concat(' ', \@$1, ' '), ' $3 ')])"; 
     101                    push @parts, "[not(contains(concat(' ', \@$1, ' '), ' $3 '))]"; 
    102102                } elsif ($2 eq '|=') { 
    103                     push @parts, ":not([\@$1='$3' or starts-with(\@$1, '$3-')])"; 
     103                    push @parts, "[not(\@$1='$3' or starts-with(\@$1, '$3-'))]"; 
    104104                } 
    105105            } elsif ($sub_rule =~ s/$reg->{attr1}//) { 
    106                 push @parts, ":not([\@$1])"; 
     106                push @parts, "[not(\@$1)]"; 
    107107            } 
    108108        } 
     
    169169=head1 CAVEATS 
    170170 
    171 =head2 NOT PSEUDO CLASS 
    172  
    173 This module supports I<:first-child> and I<:lang> pseudo class, and a 
    174 partial support for I<:not> CSS 3 pseudo class as well. When you use 
    175 I<:not>, this module will produce the equivalent XPath expression 
    176 I<:not()>, which is only available in XPath 2.0 implementation. 
    177  
    178 So far as I have tested, I<:not()> is not available in Perl XPath 
    179 modules like L<XML::LibXML> and L<HTML::Builder::XPath>. 
    180  
    181171=head2 CSS SELECTOR VALIDATION 
    182172 
  • HTML-Selector-XPath/trunk/t/02_html.t

    r1996 r1999  
    8888<div class="baz">baz</div> 
    8989 
     90=== 
     91--- input 
     92<div>foo</div> 
     93<div lang="en">baz</div> 
     94<div lang="en-us">baz</div> 
     95--- selector 
     96div:not([lang|="en"]) 
     97--- expected 
     98<div>foo</div> 
    9099 
     100=== 
     101--- input 
     102<div>foo</div> 
     103<div class="foo">baz</div> 
     104<div class="foob">baz</div> 
     105--- selector 
     106div:not([class~="foo"]) 
     107--- expected 
     108<div>foo</div> 
     109<div class="foob">baz</div> 
    91110 
     111=== 
     112--- input 
     113<div>foo</div> 
     114<div class="foo">baz</div> 
     115<div class="foob">baz</div> 
     116--- selector 
     117div:not([class]) 
     118--- expected 
     119<div>foo</div> 
     120