Skip to content

SAXEvent

do- edited this page Nov 21, 2021 · 21 revisions

Instances of this class represent SAX (or StAX) style events.

They encapsulate distinct chunks of source XML text, normally given away by XMLLexer.

Usage

const e = new SAXEvent (chunk)

if (e.type === SAXEvent.TYPES.START_ELEMENT && e.isSelfEnclosing)
  console.log (e.attributes)

Methods

Name, Parameters Return Value Description
get type SAXEvent.TYPES.* Lazy getter for the event type
get attributes Map Lazy getter for the Map of attributes
isSelfEnclosing () Boolean true iif the penultimate character is /

Members

Name Type Description
src string The original string, unparsed

Event types

This list is loosely based on JSR-000173.

Event Name Public Variable Name Description
StartDocument SAXEvent.TYPES.START_DOCUMENT <?xml ...?>, case insensitive: MAY NOT OCCUR AT ALL (if there is no prolog in the document)
ProcessingInstruction SAXEvent.TYPES.PROCESSING_INSTRUCTION any other <?...?>
Comment SAXEvent.TYPES.COMMENT <!-- ... -->
DTD SAXEvent.TYPES.DTD <!DOCTYPE ...>
StartElement SAXEvent.TYPES.START_ELEMENT <not-a-slash ...>
Characters SAXEvent.TYPES.CHARACTERS <![CDATA[...]]> contents or text without pointy braces
EndElement SAXEvent.TYPES.END_ELEMENT </...>, also emitted after StartElement for a self enclosing tag
EndDocument SAXEvent.TYPES.END_DOCUMENT Never occurs as SAXEvent.type; is included here to complete the SAXEventEmitter functionality

Clone this wiki locally