mlreportgen.dom.MessageEventData class

Package: mlreportgen.dom
Superclasses:

Holds message triggering message event

Description

Contains the message that triggered a message event.

Construction

messageEventDataObj = MessageEventData(msg) creates a message event data object that contains a DOM message (for example, a message of type mlreportgen.dom.ProgressMessage).

The DOM message dispatcher attaches an object of this type to a message event when it dispatches a message. This enables message event listeners to retrieve the dispatched message. You need to create instances of this type only if you want to create your own message dispatcher.

Input Arguments

expand all

A message object, such as an mlreportgen.dom.ProgressMessage object, that triggers a message event.

Output Arguments

expand all

Container for message triggering message event data, represented by an mlreportgen.dom.MessageEventData object.

Properties

expand all

ID for this document element, specified as a character vector. The DOM generates a session-unique ID when it creates the document element. You can specify your own ID.

The value of this read-only property is a DOM message object, such as an mlreportgen.dom.ProgressMessage object, that triggers a message event.

Tag for the document element, specified as a character vector.

The DOM generates a session-unique tag when it creates the document element. Structure the tag as class:id, where class is the class of the element and id is the value of the Id property. You can specify a tag to replace the generated tag. Specifying your own tag can make it easier to identify where an issue occurred during document generation.

Examples

collapse all

When you add a dispatcher, the DOM API creates the evtdata object, which is an mlreportgen.dom.MessageEventData object.

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test', doctype);
d.Tag = 'My report';
     
dispatcher = MessageDispatcher.getTheDispatcher;
l = addlistener(dispatcher, 'Message', ...
   @(src, evtdata) disp(evtdata.Message.formatAsText));
     
open(d);
dispatch(dispatcher, ProgressMessage('starting chapter', d));
p = Paragraph('Chapter ');
p.Tag = 'chapter title';
p.Style = { CounterInc('chapter'), CounterReset('table'), WhiteSpace('pre') };
append(p, AutoNumber('chapter'));
append(d, p);
     
close(d);
rptview('test', doctype);

Delete the listener to avoid duplicate reporting of message objects during a MATLAB® session.

delete(l);