11 Jun 2009 18:38:24 UTC
- Distribution: XML-AutoWriter
- Module version: 0.11
- Source (raw)
- Browse (raw)
- How to Contribute
- Issues (5)
- Testers (203 / 246 / 0)
- KwaliteeBus factor: 0
- % Coverage
- License: bsd
- Perl: v5.6.1
- Activity24 month
- Download (47.53KB)
- MetaCPAN Explorer
- Subscribe to distribution
- This version
- Latest version
XML::Doctype - A DTD object class
# To parse an external DTD at compile time, useful when # using XML::ValidWriter use XML::Doctype NAME => 'FooML', SYSTEM_ID => 'FooML.dtd' ; use XML::Doctype NAME => 'FooML', DTD_TEXT => $dtd ; # Parsing at run-time $doctype = XML::Doctype->new( 'FooML', SYSTEM_ID => 'FooML.dtd' ) ; # or $doctype = XML::Doctype->new() ; $doctype->parse( 'FooML', 'FooML.dtd' ) ; # Saving the parsed object open( PM, ">FooML/DTD/v1_000.pm" ) or die $! ; print PM $doctype->as_pm( 'FooML::DTD::v1_000' ) ; # Using a saved parsed DTD use FooML::DTD::v1_000 ; $doctype = FooML::DTD::v1_000->new() ;
This module parses DTDs and allows them to be saved as .pm files and reloaded. The ability to save and reload is intended to aid in packaging parsed DTDs with XML tools so that XML::Parser need not be installed.
This module is alpha code. It's developed enough to support XML::ValidWriter, but need a lot of work. Some big things that are lacking are:
methods or objects to build / traverse the DTD
$doctype = XML::Doctype->new() ; $doctype = XML::Doctype->new( 'FooML', DTD_TEXT => $doctype_text ) ; $doctype = XML::Doctype->new( 'FooML', SYSTEM_ID => 'FooML.dtd' ) ;
$name = $doctype->name() ; Sets/gets the name.
$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.
$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 = $doctype->system_id() ; Sets/gets the system ID.
$public_id = $doctype->public_id() ; Sets/gets the public_id.
$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.
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).
open( PM, "FooML/DTD/v1_001.pm" ) or die $! ; print PM $doctype->as_pm( 'FooML::DTD::v1_001' ) or die $! ; close PM or die $! ;
use FooML::DTD::v1_001 ; # Do *not* use () as a parameter list!
Returns string containing the DTD as an independant 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.
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.
This object uses the fields pragma, so you should use base and fields for any subclasses.
Barrie Slaymaker <firstname.lastname@example.org>
This module is Copyright 2000, 2005 Barrie Slaymaker. All rights reserved.
This module is licensed under your choice of the Artistic, BSD or General Public License.
2 POD Errors
The following errors were encountered while parsing the POD:
- Around line 81:
'=item' outside of any '=over'
- Around line 464:
You forgot a '=back' before '=head1'
Module Install Instructions
To install XML::AutoWriter, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell install XML::AutoWriter
For more information on module installation, please visit the detailed CPAN module installation guide.