~ubuntu-branches/ubuntu/quantal/libhtml-selector-xpath-perl/quantal

« back to all changes in this revision

Viewing changes to lib/HTML/Selector/XPath.pm

  • Committer: Package Import Robot
  • Author(s): gregor herrmann
  • Date: 2012-01-18 19:59:20 UTC
  • mfrom: (1.1.7)
  • Revision ID: package-import@ubuntu.com-20120118195920-j94ztx3i7lya5k5v
Tags: 0.14-1
* New upstream release.
* Update years of packaging copyright.

Show diffs side-by-side

added added

removed removed

Lines of Context:
2
2
 
3
3
use strict;
4
4
use 5.008_001;
5
 
our $VERSION = '0.12';
 
5
our $VERSION = '0.14';
6
6
 
7
7
require Exporter;
8
8
our @EXPORT_OK = qw(selector_to_xpath);
26
26
    # attribute value match
27
27
    attr2   => qr/^\[ \s* ($ident) \s*
28
28
        ( [~|*^\$!]? = ) \s*
29
 
        (?: ($ident) | "([^"]*)" ) \s* \] /x,
 
29
        (?: ($ident) | "([^"]*)" | '([^']*)') \s* \] /x,
30
30
    badattr => qr/^\[/,
31
31
    attrN   => qr/^:not\((.*?)\)/i, # this should be a parentheses matcher instead of a RE!
32
32
    pseudo  => qr/^:([()a-z0-9_+-]+)/i,
139
139
            } else {
140
140
                $tag = '*';
141
141
            }
 
142
            
 
143
            if (defined $parms{prefix} and not $tag =~ /[*:|]/) {
 
144
                $tag = join ':', $parms{prefix}, $tag;
 
145
            }
 
146
            
142
147
            if (! $wrote_tag++) {
143
148
                push @parts, $tag;
144
149
                $tag_index = $#parts;
294
299
 
295
300
=item selector_to_xpath
296
301
 
297
 
  $xpath = selector_to_xpath($selector);
 
302
  $xpath = selector_to_xpath($selector, %options);
298
303
 
299
304
Shortcut for C<< HTML::Selector->new(shift)->to_xpath(@_) >>. Exported upon request.
300
305
 
301
306
=item new
302
307
 
303
 
  $sel = HTML::Selector::XPath->new($selector);
 
308
  $sel = HTML::Selector::XPath->new($selector, %options);
304
309
 
305
310
Creates a new object.
306
311
 
313
318
C<root> parameter, to specify which root to start the expression. It
314
319
defaults to C</>.
315
320
 
 
321
The optional C<prefix> option allows you to specify a namespace
 
322
prefix for the generated XPath expression.
 
323
 
316
324
=back
317
325
 
318
326
=head1 SUBCLASSING NOTES