Embedix-ECD

 view release on metacpan or  search on metacpan

bin/ecd2xml  view on Meta::CPAN

    foreach (@ARGV) {
        my ($base, $path) = fileparse($_, '\..*');
        my $xecd_name = $path . $base . ".xecd";
        if ( -f $_ ) {
            open(ECD, $_) || die($!);
        } else {
            die("$_ is not a file.\n");
        }
        if (defined $opt{autowrite}) {
            open(XECD, "> $xecd_name") || die ($!);
        } else {
            *XECD = *STDOUT;
        }

        my $string = join('', <ECD>);
        close(ECD);
        if (defined $opt{keepcomments}) {
            keep_comments(*XECD, $string, \%opt);
        } else {
            ignore_comments(*XECD, $string, \%opt);
        }
        close(XECD) if (defined $opt{autowrite});
    }

} else {

    my $string = join('', <STDIN>);
    if (defined $opt{keepcomments}) {
        keep_comments(*STDOUT, $string, \%opt);
    } else {
        ignore_comments(*STDOUT, $string, \%opt);
    }

}

__END__

=head1 NAME

ecd2xml - converts text in ECD format to an XML equivalent

=head1 SYNOPSIS

=over 8

=item B<ecd2xml>

[OPTION]... [FILE]...

=item B<ecd2xml> 

[OPTION]... < STDIN > STDOUT

=back

=head1 DESCRIPTION

ecd2xml is a script that takes ECD data (whether it be in a file or
a stream), and turns it into XML.  The benefit of this is buzzword
compliance and faster parsing.  James Clark's expat can parse
busybox.xecd 60 times faster than Embedix::ECD's Parse::RecDescent
parser can parse busybox.ecd.  expat is probably more robust than
the parser I made, too.

=head1 OPTIONS

=over 4

=item -h

=item --help

This displays the help text.

=item -s n

=item -sw n

=item --shiftwidth n

This sets the number of spaces to indent for each new nesting level in the XML
document.  The default value is 2.

=item -i n

=item --indent n

This sets the number of spaces to indent the whole XML document.  The default
value is 2.

=item -a

=item --autowrite

Instead of printing the XML document to STDOUT, the document will be written
to a file of the same name as that being worked on w/ the exception that its
extension will be ".xecd" instead of ".ecd".

This option is meaningless when working with an ECD coming in from STDIN.

=item -k

=item --keepcomments

This will preserve the comments in the ECD by turning them into XML comments.
The downside of this is that although the generated XML will be well-formed,
it will not be valid according to the DTD.

=back

=head1 DIAGNOSTICS

=over 4

=item $line: was expecting $TAGNAME, but found $CRAP instead.

This error occurs whenever an imbalanced tag is found.

=item $line: $ATTRIBUTE not allowed in $NODE_TYPE

not implemented



( run in 1.419 second using v1.01-cache-2.11-cpan-39bf76dae61 )