#
# $Id: attlist.icn,v 1.2 2006-07-10 12:55:14 rparlett Exp $
#
# This file is in the public domain.
#
# Author: Robert Parlett (parlett@dial.pipex.com)
#

package xml

#
# Represent the attribute constraints for one element type.
#
class AttList(attribute_defs, has_id)
   #
   # Returns a string representation of this object.
   #
   method to_string()
      local s, x
      s := "AttList " || " "
      every x := !sort(attribute_defs) do {
         s ||:= x[1] || " " || x[2].to_string() || " "
      }
      return s
   end

   #
   # Return the attribute_defs for this AttList, being a table mapping attribute names
   # to AttributeDef objects.
   #
   method get_attribute_defs()
      return attribute_defs
   end

   #
   # Add an attribute def; called during parsing.
   #
   method add_attribute_def(name, def) 
      insert(attribute_defs, name, def)
      if \def.def_type == "ID" then
         has_id := 1
   end

   initially
      attribute_defs := table()
end
