1DTDParser(3)          User Contributed Perl Documentation         DTDParser(3)
2
3
4

NAME

6       XML::DTDParser - quick and dirty DTD parser
7
8       Version 2.01
9

SYNOPSIS

11         use XML::DTDParser qw(ParseDTD ParseDTDFile);
12
13         $DTD = ParseDTD $DTDtext;
14        #or
15         $DTD = ParseDTDFile( $dtdfile)
16

DESCRIPTION

18       This module parses a DTD file and creates a data structure containing
19       info about all tags, their allowed parameters, children, parents,
20       optionality etc. etc. etc.
21
22       Since I'm too lazy to document the structure, parse a DTD you need and
23       print the result to a file using Data::Dumper. The datastructure should
24       be selfevident.
25
26       Note: The module should be able to parse just about anything, but it
27       intentionaly looses some information.  Eg. if the DTD specifies that a
28       tag should contain either CHILD1 or CHILD2 you only get that CHILD1 and
29       CHILD2 are optional. That is is the DTD contains      <!ELEMENT FOO
30       (BAR|BAZ)> the result will be the same is if it contained
31            <!ELEMENT FOO (BAR?,BAZ?)>
32
33       You get the original unparsed parameter list as well so if you need
34       this information you may parse it yourself.
35
36       Since version 1.6 this module supports my "extensions" to DTDs.  If the
37       DTD contains a comment in form
38
39               <!--#info element=XXX foo=bar greeting="Hello World!" person='d''Artagnan'-->
40
41       and there is an element XXX in the DTD, the resulting hash for the XXX
42       will contain
43
44               'foo' => 'bar',
45               'person' => 'd\'Artagnan',
46               'greeting => 'Hello World!'
47
48       If the DTD contains
49
50               <!--#info element=XXX attribute=YYY break=no-->
51
52       the
53
54               $DTD->{XXX}->{attributes}->{YYY}->[4]
55
56       will be set to
57
58               { break => 'no' }
59
60       I use this parser to import the DTD into the database so that I could
61       map some fields to certain tags for output and I want to be able to
62       specify the mapping inside the file:
63
64               <!--#info element=TagName map_to="FieldName"-->
65
66   EXPORT
67       By default the module exports all (both) it's functions. If you only
68       want one, or none use
69
70               use XML::DTDParser qw(ParseDTD);
71               or
72               use XML::DTDParser qw();
73
74       ParseDTD
75                   $DTD = ParseDTD $DTDtext;
76
77           Parses the $DTDtext and creates a data structure. If the $DTDtext
78           contains some <!ENTITY ... SYSTEM "..."> declarations those are
79           read and parsed as needed.  The paths are relative to current
80           directory.
81
82           The module currently doesn't support URLs here yet.
83
84       ParseDTDFile
85                   $DTD = ParseDTDFile $DTDfile;
86
87           Parses the contents of $DTDfile and creates a data structure. If
88           the $DTDfile contains some <!ENTITY ... SYSTEM "..."> declarations
89           those are read and parsed as needed.  The paths are relative to the
90           $DTDfile.
91
92           The module currently doesn't support URLs here yet.
93
94       FindDTDRoot
95                   $DTD = ParseDTD $DTDtext;
96                   @roots = FindDTDRoot $DTD;
97
98           Returns all tags that have no parent. There could be several such
99           tags defined by the DTD.  Especialy if it used some common
100           includes.
101

AUTHOR

103       Jenda@Krynicky.cz http://Jenda.Krynicky.cz
104
106       Copyright (c) 2002 Jan Krynicky <Jenda@Krynicky.cz>. All rights
107       reserved.
108
109       This program is free software; you can redistribute it and/or modify it
110       under the same terms as Perl itself.
111
112
113
114perl v5.38.0                      2023-07-21                      DTDParser(3)
Impressum