XML-Parser

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN

	- Ken Beesley <ken.beesley@xrce.xerox.com> discovered that
	  declarations in the external subset are not sent to registered
	  handlers when there is no internal subset.
	- Fixed parse_dtd to work when entity values or attribute defaults
	  are so large that they might be broken across multiple calls to
	  the default handler.
	- For lwp_ext_ent_handler, use URI::URL instead of URI so that old
	  5.004 installations will work with it.
2.25 Fri Jul 23 06:23:43 EDT 1999
	- Now using Version 1990709 of expat. No local patches.
	- Numerous people reported a SEGV problem when running t/cdata
	  on various platforms and versions of perl. The problem was
	  introduced with the setHandlers change. In some cases an
	  un-initialized value was being returned.
	- Added an additional external entity handler, lwp_ext_ent_handler,
	  that deals with general URIs. It is installed instead of the
	  "file only" handler if the LWP package is installed.
2.24  Thu Jul  8 23:05:50 EDT 1999
	- KangChan Lee <dolphin@comeng.chungnam.ac.kr> supplied the
	  EUC-KR encoding map.
	- Enno Derksen <enno@att.com> forwarded reports by Jon Eisenzopf

MANIFEST  view on Meta::CPAN

README				Short explanation
README.md
samples/canonical		A utility to generate canonical XML
samples/canontst.xml		An xml document to demonstrate canonical
samples/ctest.dtd		An external DTD used by canontst.xml
samples/REC-xml-19980210.xml	The XML spec in xml form
samples/xmlcomments		A utility to extract comments
samples/xmlfilter		A utility to filter elements
samples/xmlstats		A utility to report on element statistics
t/astress.t			Test script
t/cdata.t			Test script
t/decl.t			Test script
t/defaulted.t			Test script
t/encoding.t			Test script
t/ext.ent			External entity for parament.t test
t/ext2.ent			External entity for parament.t test
t/external_ent.t		Test script
t/file.t			Test script
t/file_open_scalar.t		Test script
t/finish.t			Test script
t/foo.dtd			External DTD for parament.t test

samples/REC-xml-19980210.xml  view on Meta::CPAN

The target names "<code>XML</code>", "<code>xml</code>", and so on are
reserved for standardization in this or future versions of this
specification.
The 
XML <termref def='dt-notation'>Notation</termref> mechanism
may be used for
formal declaration of PI targets.
</p>
</div2>
 
<div2 id='sec-cdata-sect'>
<head>CDATA Sections</head>
 
<p><termdef id="dt-cdsection" term="CDATA Section"><term>CDATA sections</term>
may occur 
anywhere character data may occur; they are
used to escape blocks of text containing characters which would
otherwise be recognized as markup.  CDATA sections begin with the
string "<code>&lt;![CDATA[</code>" and end with the string
"<code>]]&gt;</code>":
<scrap lang="ebnf">

samples/xmlfilter  view on Meta::CPAN


my %keep_el;
my @keep_elpat;

my %drop_att;
my %keep_att;

my $always_true = sub { 1; };
my $root_element = '';

my $in_cdata = 0;

# Process options

while ( defined( $ARGV[0] ) and $ARGV[0] =~ /^[-+]/ ) {
    my $opt = shift;

    if ( $opt eq '-root' ) {
        $pass = 0;
    }
    elsif ( $opt eq '+root' ) {

samples/xmlfilter  view on Meta::CPAN

    ErrorContext => 2,
    Handlers     => {
        Start => \&start_handler,
        End   => \&end_handler
    }
);

if ($pass) {
    $p->setHandlers(
        Char       => \&char_handler,
        CdataStart => \&cdata_start,
        CdataEnd   => \&cdata_end
    );
}

$p->parsefile($doc);

print "</$root_element>\n"
  unless $pass;

################
## End of main

samples/xmlfilter  view on Meta::CPAN

        $sub    = $keep_sub;
    }

    if (   defined( $elref->{$el} )
        or &$sub($el)
        or check_atts( $attref, @_ ) ) {
        $pass = !$pass;
        if ($pass) {
            $xp->setHandlers(
                Char       => \&char_handler,
                CdataStart => \&cdata_start,
                CdataEnd   => \&cdata_end
            );
        }
        else {
            $xp->setHandlers(
                Char       => 0,
                CdataStart => 0,
                CdataEnd   => 0
            );
        }
        push( @togglestack, $xp->depth );

samples/xmlfilter  view on Meta::CPAN


    if ($pass) {
        print "</$el>";
    }

    if ( @togglestack and $togglestack[-1] == $xp->depth ) {
        $pass = !$pass;
        if ($pass) {
            $xp->setHandlers(
                Char       => \&char_handler,
                CdataStart => \&cdata_start,
                CdataEnd   => \&cdata_end
            );
        }
        else {
            $xp->setHandlers(
                Char       => 0,
                CdataStart => 0,
                CdataEnd   => 0
            );
        }

samples/xmlfilter  view on Meta::CPAN

    }

}    # End end_handler

sub char_handler {
    my ( $xp, $text ) = @_;

    if ( length($text) ) {

        $text = $xp->xml_escape( $text, '>' )
          unless $in_cdata;

        print $text;
    }
}    # End char_handler

sub cdata_start {
    my $xp = shift;

    print '<![CDATA[';
    $in_cdata = 1;
}

sub cdata_end {
    my $xp = shift;

    print ']]>';
    $in_cdata = 0;
}

sub check_atts {
    return $attcheck unless $attcheck;

    my $ref = shift;

    while (@_) {
        my $id  = shift;
        my $val = shift;

t/cdata.t  view on Meta::CPAN

BEGIN { print "1..2\n"; }
END { print "not ok 1\n" unless $loaded; }
use XML::Parser;
$loaded = 1;
print "ok 1\n";

my $count = 0;

my $cdata_part = "<<< & > '' << &&&>&&&&;<";

my $doc = "<foo> hello <![CDATA[$cdata_part]]> there</foo>";

my $acc = '';

sub ch {
    my ( $xp, $data ) = @_;

    $acc .= $data;
}

sub stcd {

t/cdata.t  view on Meta::CPAN

    ErrorContext => 2,
    Handlers     => {
        CdataStart => \&stcd,
        CdataEnd   => \&ecd
    }
);

$parser->parse($doc);

print "not "
  unless ( $acc eq $cdata_part );
print "ok 2\n";



( run in 0.642 second using v1.01-cache-2.11-cpan-454fe037f31 )