new
$doctype = XML::Doctype->new() ;
$doctype = XML::Doctype->new( 'FooML', DTD_TEXT => $doctype_text ) ;
$doctype = XML::Doctype->new( 'FooML', SYSTEM_ID => 'FooML.dtd' ) ;
name
$name = $doctype->name() ;
Sets/gets the name.
parse_dtd
$doctype->parse_dtd( $name, $doctype_text ) ;
$doctype->parse_dtd( $name, $doctype_text, 'internal' ) ;
Parses the text of a DTD from a scalar. $name is used to indicate the name of the DOCTYPE, and thus
the root node.
The DTD is considered to be external unless the third parameter is TRUE.
parse_dtd_file
$doctype->parse_dtd_file( $name, $system_id [, $public_id] ) ;
$doctype->parse_dtd_file( $name, $system_id [, $public_id], 'internal' ) ;
Parses a DTD from a file. Eventually will support full URL syntax.
$public_id is ignored for now, and $system_id is used to locate the DTD.
This routine requires XML::Parser. XML::Parser is not loaded at any other time and is not needed to
use the resulting DTD object.
The DTD is considered to be external unless the fourth parameter is TRUE.
$doctype->parse_dtd_file( $name, $system_id, $p_id, 'internal' ) ;
$doctype->parse_dtd_file( $name, $system_id, undef, 'internal' ) ;
system_id
$system_id = $doctype->system_id() ;
Sets/gets the system ID.
public_id
$public_id = $doctype->public_id() ;
Sets/gets the public_id.
element_decl
$elt_decl = $doctype->element_decl( $name ) ;
Returns the XML::Doctype:Element object associated with $name. These can be defined by <!ELEMENT>
tags or undefined, which can happen if they were just referred-to by <!ELEMENT> or <!ATTLIST> tags.
element_names
Returns an unsorted list of element names. This list includes names that are declared and undeclared
(but referred to in element declarations or attribute definitions).
as_pm
open( PM, "FooML/DTD/v1_001.pm" ) or die $! ;
print PM $doctype->as_pm( 'FooML::DTD::v1_001' ) or die $! ;
close PM or die $! ;
Then, later:
use FooML::DTD::v1_001 ; # Do *not* use () as a parameter list!
Returns string containing the DTD as an independent module, allowing the DTD to be parsed in the
development environment and shipped as Perl code, so that the target environment need not have
XML::Parser installed.
This is useful for XML creation-only tools and as an efficiency tuning measure if you will be
rereading the same set of DTDs over and over again.
import
use
use XML::Doctype NAME => 'FooML', SYSTEM_ID => 'dtds/FooML.dtd' ;
import() constructs a default DTD object for the calling package so that XML::ValidWriter's
functional interface can use it.
If XML::Doctype is subclassed, the subclasses' constructor is called with all parameters.