Main Content

getImpl

Class: slreportgen.report.Reporter
Namespace: slreportgen.report

Get implementation of reporter

Syntax

impl = getImpl(reporter,report)

Description

impl = getImpl(reporter,report) returns the Document Object Model (DOM) object that implements the reporter, reporter, when you append it to the report, report.

Note

You cannot add content to the reporter after calling this method.

Input Arguments

expand all

Reporter object, specified as an object of slreportgen.report.Reporter or subclass of slreportgen.report.Reporter.

Example: slreportgen.report.Diagram for a diagram reporter

Report, specified as an slreportgen.report.Report object.

Output Arguments

expand all

Implementation of the reporter, returned as a DOM object. The DOM object is usually a mlreportgen.dom.DocumentPart type object. If it is a mlreportgen.dom.DocumentPart object, the object uses the template specified by the TemplateSrc and TemplateName properties of reporter.

Examples

expand all

Use the getImpl method to obtain the DOM object used to create a diagram reporter. You can use the getImpl method with any type of reporter.

load_system("vdp")
import slreportgen.report.*
import mlreportgen.report.*
rpt = slreportgen.report.Report("output","pdf");
 
chapter = Chapter();
chapter.Title = "Diagram Reporter Example";
 
diagram = Diagram("vdp");
diagram.Snapshot.Caption = "The Van der Pol Equation";
diagram.SnapshotFormat = "svg";
diagram.Snapshot.Height = "4in";
getImpl(diagram,rpt)
ans = 
  DocumentPart with properties:

         TemplateName: 'Diagram'
         TemplatePath: '/mathworks/devel/bat/filer/batfs2566-0/Bdoc26a.3146167/build/runnable/matlab/toolbox/shared/slreportgen/rpt/rpt/+slreportgen/+report/@Diagram/resources/templates/pdf/default.pdftx'
                 Type: 'PDF'
        CurrentHoleId: '#end#'
      CurrentHoleType: 'Block'
    CurrentPageLayout: []
           OpenStatus: 'open'
               Parent: []
             Children: [1×3 mlreportgen.dom.Element]
                  Tag: 'dom.LockedDocumentPart:8'
                   Id: '8'

close(rpt);

Tips

  • Use getImpl to get information about the implementation of a reporter and use it elsewhere, such as an inline equation. See Create an Inline Equation in a Report.

  • The append method that you can use on slreportgen.report.Report objects uses getImpl to append the reporter content to the DOM document object that implements the report. You can therefore use getImpl to append reporter content to other types of DOM objects.

  • If getImpl returns a mlreportgen.dom.DocumentPart object, the method fills the holes defined in the mlreportgen.dom.DocumentPart object source template with content in the properties of the reporter that match the hole names. If the property does not exist, getImpl fills the hole without adding content to it. For example, if a reporter myReporter specifies a template with a hole MyTemplateHole, getImpl fills the hole with content in the MyTemplateHole property of the reporter, if the property exists. If you do not want getImpl to fill the holes, create a custom reporter and override this method to return an object that you can add to the DOM document, such as a string or paragraph. See Define New Custom Reporters and Modify Inherited Methods.

  • To retrieve the implementation object while also maintaining the ability to add content to the reporter, create a clone of the reporter and use getImpl on the clone.

Version History

Introduced in R2021a