| 1 | package Froody::Walker::Driver; | ||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||
| 3 | 14 | ▶ | use base 'Class::Accessor::Chained::Fast'; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 4 | |||||||||||||||||||||||||||||
| 5 | 14 | ▶ | use strict; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 6 | 14 | ▶ | use warnings; | ||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||
| 7 | |||||||||||||||||||||||||||||
| 8 | 14 | __PACKAGE__->mk_accessors(qw/walker spec/); | |||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||
| 10 | =head2 SUBCLASS METHODS | ||||||||||||||||||||||||||||
| 11 | |||||||||||||||||||||||||||||
| 12 | When writing a walker subclass, override these methods to define your | ||||||||||||||||||||||||||||
| 13 | behaviour. | ||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||
| 15 | =over | ||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||
| 17 | =item init_source( source ) | ||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||
| 19 | Should return a new, black source data structure that will be used as the source | ||||||||||||||||||||||||||||
| 20 | for the given xpath. | ||||||||||||||||||||||||||||
| 21 | |||||||||||||||||||||||||||||
| 22 | =item init_target( xpath, parent ) | ||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||
| 24 | Should return a new, blank target data structure that will be used to store data | ||||||||||||||||||||||||||||
| 25 | for the given xpath. The parent DS is passed in, in case it will depend on it in | ||||||||||||||||||||||||||||
| 26 | some way (for instance, XML::LibXML documents should be created from the same | ||||||||||||||||||||||||||||
| 27 | XML::LibXML::Document object). | ||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||
| 29 | =item validate_source( source, xpath ) | ||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||
| 31 | Should return true is the source data structure, assumed to represent the source | ||||||||||||||||||||||||||||
| 32 | at the given xpath location, validates against the local spec. | ||||||||||||||||||||||||||||
| 33 | |||||||||||||||||||||||||||||
| 34 | =item read_text( source, xpath ) | ||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||
| 36 | This method should return the text content of the node in 'source', which is in | ||||||||||||||||||||||||||||
| 37 | the original document at the given xpath location. | ||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||
| 39 | =item read_attribute( source, xpath, name ) | ||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||
| 41 | This method should return the value of the named attribute from source, which is | ||||||||||||||||||||||||||||
| 42 | in the original source document at the given location. | ||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||
| 44 | =item child_sources( source, xpath, child name ) | ||||||||||||||||||||||||||||
| 45 | |||||||||||||||||||||||||||||
| 46 | This method should return a list of new source data source elements | ||||||||||||||||||||||||||||
| 47 | under source with the given child element name. | ||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||
| 49 | =item write_text( target, xpath, value ) | ||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||
| 51 | This should insert a text value into 'target', which is in the | ||||||||||||||||||||||||||||
| 52 | target document with the given path. | ||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||
| 54 | It must return the new target object (you can modify or replace it, | ||||||||||||||||||||||||||||
| 55 | but you must return the result). | ||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||
| 57 | =item write_attribute( target, xpath, name, value ) | ||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||
| 59 | This should set the attribute on the given target to the given value. | ||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||
| 61 | It must return the new target object (you can modify or replace it, | ||||||||||||||||||||||||||||
| 62 | but you must return the result). | ||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||
| 64 | =item add_child_to_target( target, xpath, child name, child ) | ||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||
| 66 | Should add the new child object, 'child', to 'target' with the | ||||||||||||||||||||||||||||
| 67 | element name 'child name'. | ||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||
| 69 | It must return the new target object (you can modify or replace it, | ||||||||||||||||||||||||||||
| 70 | but you must return the result). | ||||||||||||||||||||||||||||
| 71 | |||||||||||||||||||||||||||||
| 72 | =item spec_for_xpath( xpath ) | ||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||
| 74 | Returns the specification for a given xpath. | ||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||
| 76 | =cut | ||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||
| 78 | 536 | ▶ | sub spec_for_xpath { | ||||||||||||||||||||||||||
|
Subroutine
spec_for_xpath: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||
| 79 | 536 | my ($self, $xpath) = @_; | |||||||||||||||||||||||||||
| 80 | 536 | my $global_spec = $self->walker->spec; | |||||||||||||||||||||||||||
| 81 | 536 | ▶ | my $spec = $global_spec->{$xpath} if $global_spec && $xpath; | ||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$global_spec and $xpath
MC/DC50%1/2
$global_spec and $xpath
$global_spec
$xpath
Truth table66%2/3
A and B
A= $global_specB= $xpath
| |||||||||||||||||||||||||||||
| 82 | 536 | return $spec; | |||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||
| 84 | } | ||||||||||||||||||||||||||||
| 85 | |||||||||||||||||||||||||||||
| 86 | =back | ||||||||||||||||||||||||||||
| 87 | |||||||||||||||||||||||||||||
| 88 | =head1 BUGS | ||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||
| 90 | None known. | ||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||
| 92 | Please report any bugs you find via the CPAN RT system. | ||||||||||||||||||||||||||||
| 93 | L<http://rt.cpan.org/NoAuth/ReportBug.html?Queue=Froody> | ||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||
| 95 | =head1 AUTHOR | ||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||
| 97 | Copyright Fotango 2005. All rights reserved. | ||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||
| 99 | Please see the main L<Froody> documentation for details of who has worked | ||||||||||||||||||||||||||||
| 100 | on this project. | ||||||||||||||||||||||||||||
| 101 | |||||||||||||||||||||||||||||
| 102 | This module is free software; you can redistribute it and/or modify it under | ||||||||||||||||||||||||||||
| 103 | the same terms as Perl itself. | ||||||||||||||||||||||||||||
| 104 | |||||||||||||||||||||||||||||
| 105 | =head1 SEE ALSO | ||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||
| 107 | L<Froody>, L<Froody::Walker> | ||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||
| 111 | 14 | 1; | |||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||
| 113 | __END__ | ||||||||||||||||||||||||||||