NAME
XML::DTD::Parser - Perl module for parsing XML DTDs
SYNOPSIS
use XML::DTD::Parser;
my $dp = new XML::DTD::Parser [ ($val) ];
DESCRIPTION
XML::DTD::Parser is a support module for top level parsing of an XML
DTD. The following methods are provided.
- new
-
my $dp = new XML::DTD::Parser [ ($val) ];
Construct a new XML::DTD::Parser object.
The parser will be validating, and hence will make parameter and character entity substitutions, if the argument
$val
is present and non-zero. - isa
-
if (XML::DTD::Parser->isa($obj) { ... }
Test object type
- parse
-
open(FH,'<file.dtd'); my $rt = ''; $dp->parse(*FH, $rt);
Parse a DTD file.
my $dtduri = 'http://nonesuch.com/MyDTD.dtd' my $dtd = LWP::Simple::get($dtduri); $dp->parse(undef, $dtd, $dtduri);
Parse a DTD from a URL.
If the parser is validating, the URI of the document containing the DTD should be passed. If it isn't, it is arbitrarily given the relative URI
unknown.dtd
.my $dp = DML::DTD::Parser->new(1); my $file = 'file.dtd' open(FH,"<$file"); my $rt = ''; $dp->parse(*FH, $rt, $file);
For a correct validating parse of a file.
If the URI isn't absolute, then it is converted into an absolute
file:
URI relative to the current working directory. The test for this assumes that the URI scheme is more than one character long, so that a DOS drive number isn't used as a scheme.Since the default URI is relative, any relative URIs in external entity declarations will be interpreted relative to a (probably non-existent) file in the parser's current working directory. In this case it's probably safest not to use relative URIs in the DTD being parsed.
The order of parsing of
$rt
and$file
is such that the internal subset can be passed in$rt
, and the external subset in$file
, however, if any of the output methods of subclass DTD is called, the result will be the merger of the internal and external subsets.
SEE ALSO
AUTHOR
Brendt Wohlberg <wohl@cpan.org>
COPYRIGHT AND LICENSE
Copyright (C) 2004-2010 by Brendt Wohlberg
This library is available under the terms of the GNU General Public License (GPL), described in the GPL file included in this distribution.
ACKNOWLEDGMENTS
Peter Lamb <Peter.Lamb@csiro.au> added fetching of external entities, improved entity substitution, and implemented more robust parsing of some classes of declaration.