Main Content

mlreportgen.dom.ListItem class

Package: mlreportgen.dom
Superclasses:

Create item for ordered or unordered list

Description

Specifies an item in an ordered (numbered) or unordered (bulleted) list.

Construction

listItemObj = ListItem() creates an empty list item.

example

listItemObj = ListItem(text) creates a list item using the specified text. The constructor creates a text object and appends the text object to the list item. In Microsoft® Word and PDF output, text in a list item is wrapped in a paragraph because Word and PDF do not permit unwrapped text in list items. In HTML output, the text is not wrapped in a paragraph.

listItemObj = ListItem(text,styleName) creates a list item using the specified text and applies the specified style.

listItemObj = ListItem(domObj) creates a list item and appends the specified document element object to the list item.

listItemObj = ListItem(domObj,styleName) creates a list item using the specified document element object and style name.

Input Arguments

expand all

The constructor creates an mlreportgen.dom.Text object for the specified text.

You can specify a Paragraph object or elements that you can append to a paragraph, including the following kinds of DOM objects:

  • mlreportgen.dom.Text

  • mlreportgen.dom.Paragraph

  • mlreportgen.dom.Image

  • mlreportgen.dom.Table

  • mlreportgen.dom.FormalTable

  • mlreportgen.dom.ExternalLink

  • mlreportgen.dom.InternalLink

  • mlreportgen.dom.CustomElement

Name of style to use for the list item, specified as a character vector.

Output Arguments

expand all

List item, represented by an mlreportgen.dom.ListItem object.

Properties

expand all

Children of this document element, specified as an array of DOM objects. This property is read-only.

Custom attributes of this document element, specified as an array of mlreportgen.dom.CustomAttribute objects. The custom attributes must be supported by the output format.

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

Format objects that specify the format of a document element.

Parent of this document element, specified as a DOM object. This property is read-only.

This property is ignored.

Tag for this document element, specified as a character vector or string scalar.

The DOM generates a session-unique tag as part of the creation of this object. The generated tag has the form CLASS:ID, where CLASS is the object class and ID is the value of the Id property of the object. Specifying your own tag value can help you to identify where an issue occurred during document generation.

Methods

Method

Purpose

append

Use ListItem.append in a similar way as you use Paragraph.append, except you can append different content to a list item than to a paragraph.

Append a character vector or any of these kinds of DOM objects to a list item:

clone

Use ListItem.clone the same way you use Paragraph.clone.

Clone a list item.

Examples

collapse all

import mlreportgen.dom.*;
doctype = 'html';
d = Document('test',doctype);
p = Paragraph('Perform the following steps.');
append(d,p);

step1 = ListItem('Do this step first.');
textForItem = Text('Next, do this.');
step2 = ListItem(textForItem);
procedure = OrderedList();
append(procedure,step1);
append(procedure,step2);
append(d,procedure);

close(d);
rptview('test',doctype);

Tips

  • Depending on how you create a multilevel list, a sublist can be a child of the parent list or a child of the preceding list item in the parent list. If the sublist is child of a list item in the parent list, the sublist inherits the formatting from the list item. If the sublist is a child of the parent list, the sublist does not inherit the formatting from the previous list item. See Format a List Item in a Multilevel List.