Plasma GitLab Archive
Projects Blog Knowledge

Class Pxp_dtd.dtd_element


class dtd_element : dtd -> string -> object .. end
A single element declaration that can be added to the DTD object. Element declarations are created by
 new dtd_element init_dtd init_name 

 This creates a new dtd_element object for init_dtd with init_name.
 The strings are represented in the same encoding as init_dtd.

method name : string
returns the name of the declared element
method externally_declared : bool
returns whether the element declaration occurs in an external entity.
method content_model : Pxp_core_types.I.content_model_type
get the content model of this element declaration, or Unspecified
method content_dfa : Pxp_dfa.dfa_definition option
return the DFA of the content model if there is a DFA, or None. A DFA exists only for regexp style content models which are deterministic.
method set_cm_and_extdecl : Pxp_core_types.I.content_model_type -> bool -> unit
set_cm_and_extdecl cm extdecl: set the content model to cm. Once the content model is not Unspecified, it cannot be set to a different value again. Furthermore, it is set whether the element occurs in an external entity (extdecl).
method encoding : Pxp_core_types.I.rep_encoding
Return the encoding of the strings
method allow_arbitrary : unit
This method sets the arbitrary_allowed flag for this element. The effect of this flag is to ignore the validation constraint that attributes for this element needs to be declared. Note that this mode is not required for implementing the well-formedness mode, because for this it is already sufficient to set the same-named flag in the global DTD object. Setting this flag for certain elements may still be useful, however. It is then possible to allow arbitrary attributes for certain elements only.

Technically, the arbitrary_allowed flag changes the behaviour of the attribute method defined below so that it raises Undeclared instead of Validation_error when an unknown attribute name is encountered.

method disallow_arbitrary : unit
Clears the arbitrary_allowed flag
method arbitrary_allowed : bool
Returns whether arbitrary attributes are allowed or not.
method attribute : string -> Pxp_core_types.I.att_type * Pxp_core_types.I.att_default
get the type and default value of a declared attribute, or raise Validation_error if the attribute does not exist. If the arbitrary_allowed flag is set, the exception Undeclared is raised instead of Validation_error.
method attribute_violates_standalone_declaration : string -> string option -> bool
attribute_violates_standalone_declaration name v: Checks whether the attribute name violates the standalone declaration if it has value v. The method returns true if:
  • The attribute declaration occurs in an external entity,
and if one of the two conditions holds:
  • v = None, and there is a default for the attribute value
  • v = Some s, and the type of the attribute is not CDATA, and s changes if normalized according to the rules of the attribute type.
The method raises Validation_error if the attribute does not exist. If the arbitrary_allowed flag is set, the exception Undeclared is raised instead of Validation_error.
method attribute_names : string list
get the list of all declared attributes
method names_of_required_attributes : string list
get the list of all attributes that are specified as required attributes
method id_attribute_name : string option
Returns the name of the attribute with type ID, or None.
method idref_attribute_names : string list
Returns the names of the attributes with type IDREF or IDREFS.
method add_attribute : string ->
Pxp_core_types.I.att_type -> Pxp_core_types.I.att_default -> bool -> unit
add_attribute name type default extdecl: add an attribute declaration for an attribute with the given name, type, and default value. If there is more than one declaration for an attribute name, the first declaration counts; the other declarations are ignored.

extdecl: if true, the attribute declaration occurs in an external entity. This property is used to check the "standalone" attribute.

method validate : unit
checks whether this element declaration (i.e. the content model and all attribute declarations) is valid for the associated DTD. Raises mostly Validation_error if the validation fails.
This web site is published by Informatikbüro Gerd Stolpmann
Powered by Caml