Data Access Routines

The following routines are defined in dtd.pl to access the data extracted from an SGML DTD:

Note:
The above routines should only be called after DTDread_dtd has been called.

Routine Descriptions

DTDget_elements

@elements = &'DTDget_elements();

DTDget_elements retrieves a sorted array of all elements defined in the DTD.

       

DTDget_top_elements

@top_elements = &'DTDget_elements();

DTDget_top_elements retrieves a sorted array of all top-most elements defined in the DTD. Top-most elements are those elements that cannot be contained within another element or can only be contained within itself.

       

DTDget_elem_attr

%attribute = &'DTDget_elem_attr($elem);

DTDget_elem_attr returns an associative array containing the attributes of $elem. The keys of the array are the attribute names, and the array values are $; separated strings of the possible values for the attributes. Example of extracting an attribute's values:

@values = split(/$;/, $attribute{`alignment'});

The first array value of the $; splitted array is the default value for the attribute (which may be an SGML reserved word). If the default value equals "#FIXED", then the next array value is the #FIXED value. The other array values are all possible values for the attribute.

Note:
$; is assumed to be the default value assigned by Perl: "\034". If $; is changed, unpredictable results may occur.
       

DTDget_parents

@parent_elements = &'DTDget_parents($elem);

DTDget_parents returns an array of all elements that may be a parent of $elem.

       

DTDget_base_children

@base_children = &'DTDget_base_children($elem, $andcon);

DTDget_base_children returns an array of the elements in the base model group of $elem. The $andcon is flag if the connector characters are included in the returned array: 0 => no connectors, 1 (non-zero) => connectors.

Example:

<!ELEMENT foo (x | y | z) +(a | b) -(m | n)>

The call &'DTDget_base_children(`foo') will return (`x', `y', `z').

The call &'DTDget_base_children(`foo', 1) will return (`(`,`x', `|', `y', `|', `z', `)'). One may use DTDis_tag_name to distinguish the element from the connectors.

Note:
The returned array may contain null string elements.
       

DTDget_exc_children

@exc_children = &'DTDget_exc_children($elem, $andcon);

DTDget_exc_children returns an array of the elements in the exclusion model group of $elem. The $andcon is flag if the connector characters are included in the returned array: 0 => no connectors, 1 (non-zero) => connectors.

Example:

<!ELEMENT foo (x | y | z) +(a | b) -(m | n)>

The call &'DTDget_exc_children(`foo') will return (`m', `n').

Note:
The returned array may contain null string elements.
       

DTDget_inc_children

@inc_children = &'DTDget_inc_children($elem, $andcon);

DTDget_inc_children returns an array of the elements in the inclusion model group of $elem. The $andcon is flag if the connector characters are included in the returned array: 0 => no connectors, 1 (non-zero) => connectors.

Example:

<!ELEMENT foo (x | y | z) +(a | b) -(m | n)>

The call &'DTDget_base_children(`foo') will return (`a', `b').

Note:
The returned array may contain null string elements.
       

Go back to dtd.pl.


Earl Hood, ehood@convex.com
dtd.pl 2.0.0