Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

xml::dtdparser(3pm) [debian man page]

DTDParser(3pm)						User Contributed Perl Documentation					    DTDParser(3pm)

NAME
XML::DTDParser - quick and dirty DTD parser Version 2.01 SYNOPSIS
use XML::DTDParser qw(ParseDTD ParseDTDFile); $DTD = ParseDTD $DTDtext; #or $DTD = ParseDTDFile( $dtdfile) DESCRIPTION
This module parses a DTD file and creates a data structure containing info about all tags, their allowed parameters, children, parents, optionality etc. etc. etc. Since I'm too lazy to document the structure, parse a DTD you need and print the result to a file using Data::Dumper. The datastructure should be selfevident. Note: The module should be able to parse just about anything, but it intentionaly looses some information. Eg. if the DTD specifies that a tag should contain either CHILD1 or CHILD2 you only get that CHILD1 and CHILD2 are optional. That is is the DTD contains <!ELEMENT FOO (BAR|BAZ)> the result will be the same is if it contained <!ELEMENT FOO (BAR?,BAZ?)> You get the original unparsed parameter list as well so if you need this information you may parse it yourself. Since version 1.6 this module supports my "extensions" to DTDs. If the DTD contains a comment in form <!--#info element=XXX foo=bar greeting="Hello World!" person='d''Artagnan'--> and there is an element XXX in the DTD, the resulting hash for the XXX will contain 'foo' => 'bar', 'person' => 'd'Artagnan', 'greeting => 'Hello World!' If the DTD contains <!--#info element=XXX attribute=YYY break=no--> the $DTD->{XXX}->{attributes}->{YYY}->[4] will be set to { break => 'no' } I use this parser to import the DTD into the database so that I could map some fields to certain tags for output and I want to be able to specify the mapping inside the file: <!--#info element=TagName map_to="FieldName"--> EXPORT By default the module exports all (both) it's functions. If you only want one, or none use use XML::DTDParser qw(ParseDTD); or use XML::DTDParser qw(); ParseDTD $DTD = ParseDTD $DTDtext; Parses the $DTDtext and creates a data structure. If the $DTDtext contains some <!ENTITY ... SYSTEM "..."> declarations those are read and parsed as needed. The paths are relative to current directory. The module currently doesn't support URLs here yet. ParseDTDFile $DTD = ParseDTDFile $DTDfile; Parses the contents of $DTDfile and creates a data structure. If the $DTDfile contains some <!ENTITY ... SYSTEM "..."> declarations those are read and parsed as needed. The paths are relative to the $DTDfile. The module currently doesn't support URLs here yet. FindDTDRoot $DTD = ParseDTD $DTDtext; @roots = FindDTDRoot $DTD; Returns all tags that have no parent. There could be several such tags defined by the DTD. Especialy if it used some common includes. AUTHOR
Jenda@Krynicky.cz http://Jenda.Krynicky.cz COPYRIGHT
Copyright (c) 2002 Jan Krynicky <Jenda@Krynicky.cz>. All rights reserved. This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. perl v5.10.1 2004-11-05 DTDParser(3pm)

Check Out this Related Man Page

XML::LibXML::Dtd(3)					User Contributed Perl Documentation				       XML::LibXML::Dtd(3)

NAME
XML::LibXML::Dtd - XML::LibXML DTD Handling SYNOPSIS
use XML::LibXML; $dtd = XML::LibXML::Dtd->new($public_id, $system_id); $dtd = XML::LibXML::Dtd->parse_string($dtd_str); $publicId = $dtd->getName(); $publicId = $dtd->publicId(); $systemId = $dtd->systemId(); DESCRIPTION
This class holds a DTD. You may parse a DTD from either a string, or from an external SYSTEM identifier. No support is available as yet for parsing from a filehandle. XML::LibXML::Dtd is a sub-class of XML::LibXML::Node, so all the methods available to nodes (particularly toString()) are available to Dtd objects. METHODS
new $dtd = XML::LibXML::Dtd->new($public_id, $system_id); Parse a DTD from the system identifier, and return a DTD object that you can pass to $doc->is_valid() or $doc->validate(). my $dtd = XML::LibXML::Dtd->new( "SOME // Public / ID / 1.0", "test.dtd" ); my $doc = XML::LibXML->new->parse_file("test.xml"); $doc->validate($dtd); parse_string $dtd = XML::LibXML::Dtd->parse_string($dtd_str); The same as new() above, except you can parse a DTD from a string. Note that parsing from string may fail if the DTD contains external parametric-entity references with relative URLs. getName $publicId = $dtd->getName(); Returns the name of DTD; i.e., the name immediately following the DOCTYPE keyword. publicId $publicId = $dtd->publicId(); Returns the public identifier of the external subset. systemId $systemId = $dtd->systemId(); Returns the system identifier of the external subset. AUTHORS
Matt Sergeant, Christian Glahn, Petr Pajas VERSION
1.70 COPYRIGHT
2001-2007, AxKit.com Ltd. 2002-2006, Christian Glahn. 2006-2009, Petr Pajas. perl v5.12.1 2009-10-07 XML::LibXML::Dtd(3)
Man Page