NAME
SGML::Element - an element of an SGML, XML, or HTML document
SYNOPSIS
$element->gi;
$element->name;
$element->attr ($attr[, $value]);
$element->attr_as_string ($attr[, $context, ...]);
$element->attributes;
$element->contents;
$element->as_string([$context, ...]);
$element->accept($visitor, ...);
$element->accept_gi($visitor, ...);
$element->children_accept($visitor, ...);
$element->children_accept_gi($visitor, ...);
DESCRIPTION
SGML::Element objects are loaded by SGML::SPGrove. An SGML::Element contains a generic identifier, or name, for the element, the elements attributes and the ordered contents of the element.
$element->gi and $element->name are synonyms, they return the generic identifier of the element.
$element->attr returns the array value of an attribute, if a second argument is given then that value is assigned to the attribute and returned. When assigning a value, attr can take an array, or an object or scalar. If given an object or scalar, attr will create an array value for it.
$element->attr_as_string returns the value of an attribute as a string, possibly modified by $context.
$element->attributes returns a reference to a hash containing the attributes of the element. The keys of the hash are the attribute names and the values are references to an array containing scalars or SGML::SData objects.
$element->contents returns a reference to an array containing the children of the element. The contents of the element may contain other elements, scalars, or SGML::SData or SGML:PI objects.
$element->as_string returns the entire hierarchy of this element as a string, possibly modified by $context. See SGML::SData and SGML::PI for more detail.
$element->accept($visitor[, ...]) issues a call back to $visitor->visit_element($element[, ...]). See examples visitor.pl and simple-dump.pl for more information.
$element->accept_gi($visitor[, ...]) issues a call back to $visitor->visit_gi_GI($element[, ...]) where GI is the generic identifier of this element. accept_gi maps strange characters in the GI to underscore (`_') [XXX more specific].
children_accept and children_accept_gi call accept and accept_gi, respectively, on each object in the element's content.
Element handles scalars internally for as_string, children_accept, and children_accept_gi. For children_accept and children_accept_gi (both), Element calls back with $visitor->visit_scalar($scalar[, ...]).
For as_string, Element will use the string unless $context->{cdata_mapper} is defined, in which case it returns the result of calling the cdata_mapper subroutine with the scalar and the remaining arguments. The actual implementation is:
&{$context->{cdata_mapper}} ($scalar, @_);
AUTHOR
Ken MacLeod, ken@bitsko.slc.ut.us
SEE ALSO
perl(1), SGML::SPGrove(3), Text::EntityMap(3), SGML::SData(3), SGML::PI(3).