| 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 ); |
| 7 | |
| 8 | my $xml =<<_xml_; |
| 9 | <foo xmlns="http://ns1" id="e1"> |
| 10 | <p:boo xmlns:p="http://ns2" id="e2"/> |
| 11 | </foo> |
| 12 | _xml_ |
| 13 | |
| 14 | $parser->set_featurescip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/set_feature().('http://xmlns.perl.org/sax/xmlns-uris', 0); |
| 15 | $parser->parse_stringscip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/parse_string().($xml); |
| 16 | $parser->set_featurescip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/set_feature().('http://xml.org/sax/features/xmlns-uris', 1); |
| 17 | $parser->parse_stringscip-perl cpan XML-SAX-ExpatXS 1.33 XML/SAX/ExpatXS/parse_string().($xml); |
| 18 | |
| 19 | #warn $handler->{data}; |
| 20 | okscip-perl cpan XML-SAX-ExpatXS 1.33 main/ok().($handler->{data} eq 'foo({}id/{}xmlns)p:boo({}id/{}p)foo({http://www.w3.org/2000/xmlns/}xmlns/{}id)p:boo({http://www.w3.org/2000/xmlns/}p/{}id)'); |
| 21 | |
| 22 | package TestHscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/; |
| 23 | #use Devel::Peek; |
| 24 | |
| 25 | 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(). } |
| 26 | |
| 27 | |
| 28 | sub start_elementscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/start_element(). { |
| 29 | my ($self, $el) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 30 | #warn("Start:$el->{Name}:$el->{Attributes}\n"); |
| 31 | #Dump($el); |
| 32 | $attsscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/$atts. = joinscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/join().('/', sortscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/sort(). keysscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/keys(). %{$el->{Attributes}}); |
| 33 | $self->{data} .= "$el->{Name}($atts)"; |
| 34 | } |
| 35 | |
| 36 | sub end_elementscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/end_element(). { |
| 37 | my ($self, $el) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 38 | #warn("End:$el->{Name}\n"); |
| 39 | #Dump($el); |
| 40 | } |
| 41 | |
| 42 | sub start_prefix_mappingscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/start_prefix_mapping(). { |
| 43 | my ($self, $map) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 44 | #warn("sPref:$map->{Prefix}\n"); |
| 45 | #Dump($map); |
| 46 | #$self->{data} .= "sP($map->{Prefix}:$map->{NamespaceURI})"; |
| 47 | } |
| 48 | |
| 49 | sub end_prefix_mappingscip-perl cpan XML-SAX-ExpatXS 1.33 TestH/end_prefix_mapping(). { |
| 50 | my ($self, $map) = @_scip-perl cpan XML-SAX-ExpatXS 1.33 TestH/`@_`.; |
| 51 | #warn("ePref:$map->{Prefix}\n"); |
| 52 | #Dump($map); |
| 53 | #$self->{data} .= "eP($map->{Prefix})"; |
| 54 | } |