| 1 | use Testscip-perl cpan XML-SAX-ExpatXS 1.33 Test/; |
| 2 | BEGIN { planscip-perl cpan XML-SAX-ExpatXS 1.33 main/plan(). tests => 1 } |
| 3 | use XML::SAX::ExpatXSscip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/; |
| 4 | |
| 5 | my $handler = TestH->newscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/new().(); |
| 6 | my $parser = XML::SAX::ExpatXS->newscip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/new().( Handler => $handler, NoExpand => 1 ); |
| 7 | |
| 8 | my $xml =<<_xml_; |
| 9 | <?xml version="1.0" encoding="utf-8"?> |
| 10 | <!DOCTYPE root [ |
| 11 | <!ENTITY internal "int_entity_value"> |
| 12 | ]> |
| 13 | <root> |
| 14 | &internal; |
| 15 | </root> |
| 16 | _xml_ |
| 17 | |
| 18 | $parser->parse_stringscip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/parse_string().($xml); |
| 19 | |
| 20 | #warn $handler->{data}; |
| 21 | okscip-perl cpan XML-SAX-ExpatXS 1.33 main/ok().($handler->{data} eq '_sD_sDtd_iDec(internal,int_entity_value)_eDtd_sE(root)_ch(N)_ch(N)_eE_eD'); |
| 22 | |
| 23 | package TestHscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/; |
| 24 | #use Devel::Peek; |
| 25 | |
| 26 | sub newscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/new(). { blessscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/bless(). {data => ''}, shiftscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/shift(). } |
| 27 | |
| 28 | sub start_documentscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/start_document(). { |
| 29 | my ($self, $doc) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 30 | #warn("StartDoc:\n"); |
| 31 | #Dump($el); |
| 32 | $self->{data} .= '_sD'; |
| 33 | } |
| 34 | |
| 35 | sub end_documentscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/end_document(). { |
| 36 | my ($self, $doc) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 37 | #warn("EndDoc:\n"); |
| 38 | #Dump($el); |
| 39 | $self->{data} .= '_eD'; |
| 40 | } |
| 41 | |
| 42 | sub start_elementscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/start_element(). { |
| 43 | my ($self, $el) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 44 | #warn("StartEl:\n"); |
| 45 | #Dump($el); |
| 46 | $self->{data} .= "_sE($el->{Name})"; |
| 47 | } |
| 48 | |
| 49 | sub end_elementscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/end_element(). { |
| 50 | my ($self, $el) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 51 | #warn("EndEl:\n"); |
| 52 | #Dump($el); |
| 53 | $self->{data} .= '_eE'; |
| 54 | } |
| 55 | |
| 56 | sub start_dtdscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/start_dtd(). { |
| 57 | my ($self, $dtd) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 58 | #warn("StartDTD:\n"); |
| 59 | #Dump($el); |
| 60 | $self->{data} .= '_sDtd'; |
| 61 | } |
| 62 | |
| 63 | sub end_dtdscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/end_dtd(). { |
| 64 | my ($self, $dtd) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 65 | #warn("EndDTD:\n"); |
| 66 | #Dump($dtd); |
| 67 | $self->{data} .= '_eDtd'; |
| 68 | } |
| 69 | |
| 70 | sub internal_entity_declscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/internal_entity_decl(). { |
| 71 | my ($self, $ent) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 72 | #warn("IntEntDecl:$ent->{Name}\n"); |
| 73 | #Dump($ent); |
| 74 | $self->{data} .= "_iDec($ent->{Name},$ent->{Value})"; |
| 75 | } |
| 76 | |
| 77 | sub charactersscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/characters(). { |
| 78 | my ($self, $ch) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 79 | $ch->{Data} =~ s/\n/N/g; |
| 80 | #warn("Char:$ch->{Data}\n"); |
| 81 | #Dump($ch); |
| 82 | $self->{data} .= "_ch($ch->{Data})"; |
| 83 | } |