Referencecollect

<collect>

Collects descendants of a component matching a specified component type

<collect> is a General Operator component that gathers discrete component data from a graph or sectional component and stores it in an array.

Attributes and Properties

Attributes for <collect>

Other (4)
asList

boolean. Default value: true. Whether to render the items separated by commas (true) or with no separator (false).

text. Component type of descendants to collect.

reference. Component subtree(s) to collect descendants from.

number. Maximum number of descendants to collect.

Common to all components (4)
copy

reference. Create an independent copy of another component by reference. Enter a references a $name.

extend

reference. Extend another component by reference, inheriting its children and attributes. Enter a reference as $name.

fixLocation

boolean. Default value: false. Whether this component's location is fixed (preventing it from being moved while still allowing other modifications).

name

text. The name used to reference this component from elsewhere in the document.

Properties for <collect name="c">

Other (1)
$c.maxNumber

number. Maximum number of descendants to collect.

Common to all components (1)
$c.doenetML

text. The DoenetML source code that produced this component.

Examples

Example: Collect <point> children from a <graph>

The <collect/> component is used to gather <point> children from a named <graph>.


Example: Collect <textInput> children from a <repeat>

The <collect/> component is used to gather <textInput> components generated by a <repeat>.


Example: Collect user-added <point> children to draw a <polygon>

The <collect/> component is used to gather <point> components generated by two <callAction> components within a <graph>. The named <collect/> is then referenced in the vertices attribute of a <polygon>.


Example: <collect> function data

The <collect> can be used for function components as well as graphical components and that the set of data collected need not be contained in a graph. Any sectional component or module can be used with the from attribute inside the <collect> component.


Example: Collecting a property of a component

To access an individual property of a group of collected components, refer to the name of the <collect> followed by the property name, such as radius in this example.

In order to access a specific component’s property, use the index of the component in square brackets, such as $collectRadii[2].radius.

Attribute Examples

Attribute Example: from

The from attribute specifies which named component the <collect> is gathering information from.


Attribute Example: componentType

The componentType attribute specifies the type of component that is being collected from the reference listed in from.


Attribute Example: maxNumber

The maxNumber attribute sets a limit on the number of components to collect.