.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "DTDParser 3pm" .TH DTDParser 3pm "2021-01-05" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" XML::DTDParser \- quick and dirty DTD parser .PP Version 2.01 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use XML::DTDParser qw(ParseDTD ParseDTDFile); \& \& $DTD = ParseDTD $DTDtext; \& #or \& $DTD = ParseDTDFile( $dtdfile) .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" This module parses a \s-1DTD\s0 file and creates a data structure containing info about all tags, their allowed parameters, children, parents, optionality etc. etc. etc. .PP Since I'm too lazy to document the structure, parse a \s-1DTD\s0 you need and print the result to a file using Data::Dumper. The datastructure should be selfevident. .PP Note: The module should be able to parse just about anything, but it intentionaly looses some information. Eg. if the \s-1DTD\s0 specifies that a tag should contain either \s-1CHILD1\s0 or \s-1CHILD2\s0 you only get that \&\s-1CHILD1\s0 and \s-1CHILD2\s0 are optional. That is is the \s-1DTD\s0 contains the result will be the same is if it contained .PP You get the original unparsed parameter list as well so if you need this information you may parse it yourself. .PP Since version 1.6 this module supports my \*(L"extensions\*(R" to DTDs. If the \s-1DTD\s0 contains a comment in form .PP .Vb 1 \& .Ve .PP and there is an element \s-1XXX\s0 in the \s-1DTD,\s0 the resulting hash for the \s-1XXX\s0 will contain .PP .Vb 3 \& \*(Aqfoo\*(Aq => \*(Aqbar\*(Aq, \& \*(Aqperson\*(Aq => \*(Aqd\e\*(AqArtagnan\*(Aq, \& \*(Aqgreeting => \*(AqHello World!\*(Aq .Ve .PP If the \s-1DTD\s0 contains .PP .Vb 1 \& .Ve .PP the .PP .Vb 1 \& $DTD\->{XXX}\->{attributes}\->{YYY}\->[4] .Ve .PP will be set to .PP .Vb 1 \& { break => \*(Aqno\*(Aq } .Ve .PP I use this parser to import the \s-1DTD\s0 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: .PP .Vb 1 \& .Ve .SS "\s-1EXPORT\s0" .IX Subsection "EXPORT" By default the module exports all (both) it's functions. If you only want one, or none use .PP .Vb 3 \& use XML::DTDParser qw(ParseDTD); \& or \& use XML::DTDParser qw(); .Ve .IP "ParseDTD" 4 .IX Item "ParseDTD" .Vb 1 \& $DTD = ParseDTD $DTDtext; .Ve .Sp Parses the \f(CW$DTDtext\fR and creates a data structure. If the \f(CW$DTDtext\fR contains some declarations those are read and parsed as needed. The paths are relative to current directory. .Sp The module currently doesn't support URLs here yet. .IP "ParseDTDFile" 4 .IX Item "ParseDTDFile" .Vb 1 \& $DTD = ParseDTDFile $DTDfile; .Ve .Sp Parses the contents of \f(CW$DTDfile\fR and creates a data structure. If the \f(CW$DTDfile\fR contains some declarations those are read and parsed as needed. The paths are relative to the \f(CW$DTDfile\fR. .Sp The module currently doesn't support URLs here yet. .IP "FindDTDRoot" 4 .IX Item "FindDTDRoot" .Vb 2 \& $DTD = ParseDTD $DTDtext; \& @roots = FindDTDRoot $DTD; .Ve .Sp Returns all tags that have no parent. There could be several such tags defined by the \s-1DTD.\s0 Especialy if it used some common includes. .SH "AUTHOR" .IX Header "AUTHOR" Jenda@Krynicky.cz http://Jenda.Krynicky.cz .SH "COPYRIGHT" .IX Header "COPYRIGHT" Copyright (c) 2002 Jan Krynicky . All rights reserved. .PP This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.