SGML::Util - miscellaneous utility functions for SGML processing
use SGML::Util; %attrs = SGMLparse_attr_spec($attr_spec); $attr_spec = SGMLattr_to_sgml(\%attrs); if (SGMLopen_lit($str)) { ... }
SGML::Util contains miscellaneous utility functions related to SGML processing. The following functions are exported by SGML::Util:
@nv_list = SGMLparse_attr_spec($attr_spec); %attrs = SGMLparse_attr_spec($attr_spec);
An array of name value pairs.
SGMLparse_attr_spec takes a attribute specification string and parses it into a list of name/value pairs. An example attribute specification string:
border=0 WIDTH="100%" CellSpacing=2 cellpadding = '4'
Any non-whitespace character in $attr_spec is treated as a name character. This allows the parsing of SGML-like markup. For example, the following will not generate a complaint:
% = 100 width = 100%
The calling routine can assign the return value to a hash to allow easy access to attribute values. The name/value pairs occur in the same order as listed in the specification list.
All attribute names are converted to lowercase.
Attribute values w/o a name are given a bogus name of the reserved name indicator ('#' in the reference concrete syntax) with a number appended (eg. "#4"). This is to handle the case when SHORTTAG is YES.
$attr_spec = SGMLattr_to_sgml(\%attrs); $attr_spec = SGMLattr_to_sgml(\@nv_list);
An SGML attribution specification list string.
SGMLattr_to_sgml is the inverse operation of SGMLparse_attr_spec. It takes a attribute structure and generates the SGML markup representation.
Attribute names starting with the reserved name indicator ('#' in the reference concrete syntax) are skipped with only their values printed. This is to handle the case when SHORTTAG is YES.
if (SGMLopen_lit($str)) { # ... }
1 if open literal, else 0.
SGMLopen_lit checks if a string has a literal that is not closed. I.e. If there is a quote without a matching quote, the routine will return true.
perl(1)
This software is part of the perlSGML package; see (http://www.oac.uci.edu/indiv/ehood/perlSGML.html)