class
XML::SAX::Handlers
- XML::SAX::Handlers
- Reference
- Object
Direct Known Subclasses
Defined in:
sax/handlers.crInstance Method Summary
-
#attlist_decl(element_name : String, name : String, type : Symbol, names : Array(String) | Nil, default : Symbol, value : String | Nil) : Nil
Called for attribute declarations in a DTD.
-
#cdata_section(data : String) : Nil
Called for CDATA sections.
-
#character_data(data : String) : Nil
Called for text.
-
#comment(data : String) : Nil
Called for comments.
-
#element_decl(name : String, content : ElementDecl) : Nil
Called for element declarations in a DTD.
-
#empty_element(name : String, attributes : Array(Tuple(String, String))) : Nil
Called for an empty element tag.
-
#end_doctype_decl : Nil
Called at the and of a DOCTYPE declaration.
-
#end_element(name : String) : Nil
Called at the end of an element tag.
-
#entity_decl(entity : Entity) : Nil
Called for entity declarations in a DTD.
-
#entity_reference(name : String)
Called when trying to expand an undeclared or invalid entity within character data.
-
#error(message : String, location : Location)
Called when a recoverable error happens.
-
#notation_decl(name : String, public_id : String | Nil, system_id : String | Nil) : Nil
Called for notation declarations in a DTD.
-
#open_external(base : String | Nil, uri : String, & : String, IO -> ) : Nil
Called when trying to open an external entity or doctype.
- #open_external(base : String | Nil, uri : String) : Tuple(String, IO) | Nil
-
#processing_instruction(target : String, data : String) : Nil
Called for processing instructions.
-
#start_doctype_decl(name : String, system_id : String | Nil, public_id : String | Nil, intsubset : Bool)
Called at the start of a DOCTYPE declaration.
-
#start_element(name : String, attributes : Array(Tuple(String, String))) : Nil
Called at the start of an element tag.
-
#text_decl(version : String, encoding : String | Nil) : Nil
Called for text declarations in parsed external entities.
-
#xml_decl(version : String, encoding : String | Nil, standalone : Bool | Nil) : Nil
Called for XML declarations.
Instance Method Detail
Called for attribute declarations in a DTD.
Called for every attribute in attlist declaration: if an attlist has multiple attribute declarations, the method will be called for each one.
- element_name is the element name the attribute is declared for.
- name is the attribute name.
- type is the attribute type as a symbol, for example
:CDATA,:IDREFS,:NOTATIONor:ENUMERATION. - names an array of names if type is
:NOTATIONor:ENUMERATION, nil otherwise. - default can be
:REQUIRED,:IMPLIEDor:FIXED. - value is the default value when default is
:FIXED, nil otherwise.
Called for CDATA sections.
- data is all the text inside the data section.
Called for text.
It might be called multiple times for a single contiguous text in a XML document (for example because we processed an entity). You might have to concatenate data when searching for some pattern in text, or to build a single text node in a DOM tree.
Called for element declarations in a DTD.
- name is the declared element name.
- content is the declared element model.
Called for an empty element tag.
See #start_element for details.
Unless overridden, calls #start_element then #end_element by default.
Called for entity declarations in a DTD.
- entity is the declared entity definition.
Called when trying to expand an undeclared or invalid entity within character data.
Called when a recoverable error happens.
- message details the error.
- location is the line/column where the parser reached the error.
Unless overridden, raises an Error by default.
Called for notation declarations in a DTD.
- name is the declared notation name.
- system_id and public_id will be nil when unspecified.
Called when trying to open an external entity or doctype.
The IO should be closed after the block has returned.
Called for processing instructions.
- target is the first word in the processing instruction.
- data is the rest of the instruction.
Called at the start of a DOCTYPE declaration.
- name is the root element name.
- system_id and public_id will be nil when unspecified.
- intsubset is true when the doctype has an internal subset declaration.
Called at the start of an element tag.
- name is the tag name.
- attributes is an array of attribute name/value tuples.
The attributes array presents the attributes in the order they have been parsed. If an attribute is present twice with the same name, there will be two entries in the array.
Called for text declarations in parsed external entities.
- version defaults to
"1.0". - encoding may be nil, in which case the parser assumes UTF-8 or the detected encoding.
Called for XML declarations.
- version defaults to
"1.0". - encoding may be nil, in which case the parser assumes UTF-8 or the detected encoding.
- standalone will be nil when unspecified.