Name

SGML::Util - miscellaneous utility functions for SGML processing


Synopsis

    use SGML::Util;
    %attrs = SGMLparse_attr_spec($attr_spec);
    $attr_spec = SGMLattr_to_sgml(\%attrs);
    if (SGMLopen_lit($str)) { ... }

Description

SGML::Util contains miscellaneous utility functions related to SGML processing. The following functions are exported by SGML::Util:


SGMLparse_attr_spec

    @nv_list = SGMLparse_attr_spec($attr_spec);
    %attrs   = SGMLparse_attr_spec($attr_spec);

Arguments:

$attr_spec
A scalar string representing the SGML attribute specificaion list. The stago, gi, and etago should NOT be in the specification list string.

Return:

An array of name value pairs.

Description:

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.


SGMLattr_to_sgml

    $attr_spec = SGMLattr_to_sgml(\%attrs);
    $attr_spec = SGMLattr_to_sgml(\@nv_list);

Arguments:

\%attrs
\@nv_list
A reference to a hash or an array. If a hash, the keys represent the names and the values the attribute values. If an array, the array is interpreted as a sequence of name/value pairs.

Return:

An SGML attribution specification list string.

Description:

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.


SGMLopen_lit

    if (SGMLopen_lit($str)) {
	# ...
    }

Parameters

$str
Scalar string to check.

Return:

1 if open literal, else 0.

Description

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.


See Also

SGML::Parser

perl(1)


Availability

This software is part of the perlSGML package; see (http://www.oac.uci.edu/indiv/ehood/perlSGML.html)


Author

Earl Hood
ehood@medusa.acs.uci.edu
Copyright © 1997

97/09/18 14:32:49