Skip Menu |
 

This queue is for tickets about the XML-Twig CPAN distribution.

Report information
The Basics
Id: 83264
Status: resolved
Priority: 0/
Queue: XML-Twig

People
Owner: Nobody in particular
Requestors: HMBRAND [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 3.42
Fixed in: 3.44



Subject: Doc fixes
Download (untitled) / with headers
text/plain 4.2k
Here are some techinical fixes for your documentation where code snippets - including examples - had syntax errors: --- a/XML/Twig.pm 2013-02-11 15:13:43.231156933 +0100 +++ b/XML/Twig.pm 2013-02-11 15:34:48.111256684 +0100 @@ -9948,7 +9948,7 @@ confuse XML::Twig ;--( Note: you can set handlers (twig_handlers) using twig_roots Example: my $t= XML::Twig->new( twig_roots => - { title => sub { $_{1]->print;}, + { title => sub { $_[1]->print;}, subtitle => \&process_subtitle } ); @@ -9968,7 +9968,7 @@ value this will print the document outsi sub number_title { my( $twig, $title); $nb++; - $title->prefix( "$nb "; } + $title->prefix( "$nb "); $title->print; } } @@ -9991,7 +9991,7 @@ C<twig_roots> elements will be output to sub number_title { my( $twig, $title); $nb++; - $title->prefix( "$nb "; } + $title->prefix( "$nb "); $title->print( $out); # you have to print to \*OUT here } } @@ -10610,14 +10610,14 @@ example: # using an array ref my $t= XML::Twig->new( index => [ 'div', 'table' ]) - ->parsefile( "foo.xml'); + ->parsefile( "foo.xml"); my $divs= $t->index( 'div'); my $first_div= $divs->[0]; my $last_table= $t->index( table => -1); # using a hashref to name the indexes - my $t= XML::Twig->new( index => { email => 'a[@href=~/^\s*mailto:/]') - ->parsefile( "foo.xml'); + my $t= XML::Twig->new( index => { email => 'a[@href=~/^ \s*mailto:/]'}) + ->parsefile( "foo.xml"); my $last_emails= $t->index( email => -1); Note that the index is not maintained after the parsing. If elements are @@ -10630,7 +10630,7 @@ creates methods that give direct access my $t= XML::Twig->new( att_accessors => [ 'href', 'src']) ->parsefile( $file); - my $first href= $t->first_elt( 'img')->src; # same as ->att( 'src') + my $first_href= $t->first_elt( 'img')->src; # same as ->att( 'src') $t->first_elt( 'img')->src( 'new_logo.png') # changes the attribute value =item elt_accessors @@ -10645,7 +10645,7 @@ or in a hash alias => expression my $title_text= $t->root->head->field( 'title'); # same as $title_text= $t->root->first_child( 'head')->field ( 'title'); - my $t= XML::Twig->new( elt_accessors => { warnings => 'p [@class="warning"]', d2 => 'div[2]', ) + my $t= XML::Twig->new( elt_accessors => { warnings => 'p [@class="warning"]', d2 => 'div[2]', }) ->parsefile( $file); my $body= $t->first_elt( 'body'); my @warnings= $body->warnings; # same as $body->children( 'p [@class="warning"]'); @@ -11747,7 +11747,7 @@ The C<$optional_elt> is the root of a su subtree then the method returns undef. You can then walk a sub-tree with: my $elt= $subtree_root; - while( $elt= $elt->next_elt( $subtree_root) + while( $elt= $elt->next_elt( $subtree_root)) { # insert processing code here } @@ -12321,8 +12321,8 @@ of the element. B<Bug>: in the C<$regexp>, you can only use C<\1>, C<\2>... if the replacement expression does not include elements or attributes. eg - t->subs_text( qr/((t[aiou])\2)/, '$2'); # ok, replaces toto, tata, titi, tutu by to, ta, ti, tu - t->subs_text( qr/((t[aiou])\2)/, '&elt(p => $1)' ); # NOK, does not find toto... + $t->subs_text( qr/((t[aiou])\2)/, '$2'); # ok, replaces toto, tata, titi, tutu by to, ta, ti, tu + $t->subs_text( qr/((t[aiou])\2)/, '&elt(p => $1)' ); # NOK, does not find toto... =item add_id ($optional_coderef) @@ -12564,7 +12564,7 @@ table for example. Optionally each tag can be followed by a hashref of attributes, that will be set on the wrapping element: - $elt->wrap_in( p => { class => "advisory" }, div => { class => "intro", id => "div_intro }); + $elt->wrap_in( p => { class => "advisory" }, div => { class => "intro", id => "div_intro" }); =item insert_new_elt ($opt_position, $tag, $opt_atts_hashref, @opt_content) -->8---
Subject: Re: [rt.cpan.org #83264] Doc fixes
Date: Tue, 12 Feb 2013 11:40:27 +0100
To: bug-XML-Twig [...] rt.cpan.org
From: mirod <xmltwig [...] gmail.com>
Download (untitled) / with headers
text/plain 4.9k
Thanks, applied to the development version. -- mirod On 02/11/2013 03:53 PM, H.Merijn Brand via RT wrote: Show quoted text
> Mon Feb 11 09:53:34 2013: Request 83264 was acted upon. > Transaction: Ticket created by HMBRAND > Queue: XML-Twig > Subject: Doc fixes > Broken in: 3.42 > Severity: Important > Owner: Nobody > Requestors: HMBRAND@cpan.org > Status: new > Ticket <URL: https://rt.cpan.org/Ticket/Display.html?id=83264 > > > > Here are some techinical fixes for your documentation where code > snippets - including examples - had syntax errors: > > --- a/XML/Twig.pm 2013-02-11 15:13:43.231156933 +0100 > +++ b/XML/Twig.pm 2013-02-11 15:34:48.111256684 +0100 > @@ -9948,7 +9948,7 @@ confuse XML::Twig ;--( > > Note: you can set handlers (twig_handlers) using twig_roots > Example: my $t= XML::Twig->new( twig_roots => > - { title => sub { $_{1]->print;}, > + { title => sub { $_[1]->print;}, > subtitle => \&process_subtitle > } > ); > @@ -9968,7 +9968,7 @@ value this will print the document outsi > sub number_title > { my( $twig, $title); > $nb++; > - $title->prefix( "$nb "; } > + $title->prefix( "$nb "); > $title->print; > } > } > @@ -9991,7 +9991,7 @@ C<twig_roots> elements will be output to > sub number_title > { my( $twig, $title); > $nb++; > - $title->prefix( "$nb "; } > + $title->prefix( "$nb "); > $title->print( $out); # you have to print to \*OUT > here > } > } > @@ -10610,14 +10610,14 @@ example: > > # using an array ref > my $t= XML::Twig->new( index => [ 'div', 'table' ]) > - ->parsefile( "foo.xml'); > + ->parsefile( "foo.xml"); > my $divs= $t->index( 'div'); > my $first_div= $divs->[0]; > my $last_table= $t->index( table => -1); > > # using a hashref to name the indexes > - my $t= XML::Twig->new( index => { email => 'a[@href=~/^\s*mailto:/]') > - ->parsefile( "foo.xml'); > + my $t= XML::Twig->new( index => { email => 'a[@href=~/^ > \s*mailto:/]'}) > + ->parsefile( "foo.xml"); > my $last_emails= $t->index( email => -1); > > Note that the index is not maintained after the parsing. If elements > are > @@ -10630,7 +10630,7 @@ creates methods that give direct access > > my $t= XML::Twig->new( att_accessors => [ 'href', 'src']) > ->parsefile( $file); > - my $first href= $t->first_elt( 'img')->src; # same as ->att( 'src') > + my $first_href= $t->first_elt( 'img')->src; # same as ->att( 'src') > $t->first_elt( 'img')->src( 'new_logo.png') # changes the attribute > value > > =item elt_accessors > @@ -10645,7 +10645,7 @@ or in a hash alias => expression > my $title_text= $t->root->head->field( 'title'); > # same as $title_text= $t->root->first_child( 'head')->field > ( 'title'); > > - my $t= XML::Twig->new( elt_accessors => { warnings => 'p > [@class="warning"]', d2 => 'div[2]', ) > + my $t= XML::Twig->new( elt_accessors => { warnings => 'p > [@class="warning"]', d2 => 'div[2]', }) > ->parsefile( $file); > my $body= $t->first_elt( 'body'); > my @warnings= $body->warnings; # same as $body->children( 'p > [@class="warning"]'); > @@ -11747,7 +11747,7 @@ The C<$optional_elt> is the root of a su > subtree then the method returns undef. You can then walk a sub-tree > with: > > my $elt= $subtree_root; > - while( $elt= $elt->next_elt( $subtree_root) > + while( $elt= $elt->next_elt( $subtree_root)) > { # insert processing code here > } > > @@ -12321,8 +12321,8 @@ of the element. > B<Bug>: in the C<$regexp>, you can only use C<\1>, C<\2>... if the > replacement > expression does not include elements or attributes. eg > > - t->subs_text( qr/((t[aiou])\2)/, '$2'); # ok, replaces > toto, tata, titi, tutu by to, ta, ti, tu > - t->subs_text( qr/((t[aiou])\2)/, '&elt(p => $1)' ); # NOK, does not > find toto... > + $t->subs_text( qr/((t[aiou])\2)/, '$2'); # ok, replaces > toto, tata, titi, tutu by to, ta, ti, tu > + $t->subs_text( qr/((t[aiou])\2)/, '&elt(p => $1)' ); # NOK, does not > find toto... > > =item add_id ($optional_coderef) > > @@ -12564,7 +12564,7 @@ table for example. > Optionally each tag can be followed by a hashref of attributes, that > will be > set on the wrapping element: > > - $elt->wrap_in( p => { class => "advisory" }, div => { class => > "intro", id => "div_intro }); > + $elt->wrap_in( p => { class => "advisory" }, div => { class => > "intro", id => "div_intro" }); > > =item insert_new_elt ($opt_position, $tag, $opt_atts_hashref, > @opt_content) > > -->8--- >
From: dsteinbrunner [...] pobox.com
Download (untitled) / with headers
text/plain 141b
On Tue Feb 12 05:41:03 2013, xmltwig@gmail.com wrote: Show quoted text
> Thanks, applied to the development version.
It appears this ticket can be closed now


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.