NAME

XML::DTD::ContentModel - Perl module representing an element content model in an XML DTD

SYNOPSIS

use XML::DTD::ContentModel;

my $cm = XML::DTD::ContentModel->new('(a,b*,(c|d)+)');
print $cm->treestring;

DESCRIPTION

XML::DTD::ContentModel is a Perl module representing an element content model in an XML DTD. The following methods are provided.

new
my $cm = XML::DTD::ContentModel->new('(a,b*,(c|d)+)');

Construct a new XML::DTD::ContentModel object.
isa
if (XML::DTD::ContentModel->isa($obj) {
...
}

Test object type.

children
my $objlst = $cm->children;

Return the list of child objects (subexpressions).

my $objlst = $cm->children($children);

Sets the list of child objects (subexpressions). Returns the new value.

element
my $name = $cm->element;

Return the element name if the object has no subexpressions.

my $name = $cm->element($elename);

Set the element name. The element name should only be set if the object has no subexpressions. Returns the new value.

combineop
my $op = $cm->combineop;

Return the combination operator (",", "|" or undef).

my $op = $cm->combineop($combineop);

Set the combination operator (",", "|", or undef). Returns the new value.

occurop
my $op = $cm->occurop;

Return the occurrence operator ("?", "+", "*", or undef).

my $op = $cm->occurop($occurop);

Set the occurrence operator ("?", "+", "*", or undef). Returns the new value.

isatomic
if ($cm->isatomic) {
...
}

Determine whether the object is atomic (i.e. the model consists of a single element, ANY, EMPTY, or #PCDATA).

childnames
my $nmlst = $cm->childnames;

Return a list of contained elements.
string
print $cm->string;

Return a string representation of the content model.

treestring
print $cm->treestring;

Return a string representing the hierarchical structure of the model.

writexmlelts
open(FH,'>file.xml');
my $xo = new XML::Output({'fh' => *FH});
$cm->writexmlelts($xo);

Write a component-specific part of the XML representation.

type
my $typstr = $cm->type;

Determine the content specification type ('empty', 'any', 'mixed', or 'element').

dfa
my $dfa = $cm->dfa;

Construct a Deterministic Finite Automaton to validate the content model.

SEE ALSO

XML::DTD, XML::DTD::Element, XML::DTD::Automaton

AUTHOR

Brendt Wohlberg <wohl@cpan.org>

COPYRIGHT AND LICENSE

Copyright (C) 2006-2007 by Brendt Wohlberg

This library is available under the terms of the GNU General Public License (GPL), described in the GPL file included in this distribution.

ACKNOWLEDGMENTS

Peter Lamb <Peter.Lamb@csiro.au> fixed a bug in the _parse function, provided an improved implementation of _parenmatch, and modified accessor methods to allow setting of relevant values.