B.2 Bind Templates

The bind language provides an ability to create copies of template objects, based on the shape of the input data. Diagrams are frequently composed of sections, where those sections are filled with instances of various elements related to the section. Similar visual representations are often used to for display, but each figure is customized in certain ways. An icon representing a server can be the same across all server depictions, but the fill color of the icon could be derived from the server’s state.

The following subsections describe the attributes, commands, and variables for bind templates:

B.2.1 Bind Attributes

The following are valid bind attributes:

  • target: Contains an element reference to the element that will be the parent SVG element to any newly created child objects.

    By default this is the parent element of the bind:templates command. Several steps are performed to attempt to locate a different element target:

    1. If the element reference begins with the # character, the rest of the reference designates an XML element directly by ID lookup.

    2. If the element reference is nonempty and does not begin with the # character, it is interpreted as an XPath expression rooted at the command. XPath provides a powerful ability to use relative navigation and querying to specify the element to use.

    3. If the element reference is empty, the siblings of the command is searched to see if any of them possess a bind:container attribute. If more than one sibling has the bind:container attribute, the closest is chosen (by distance).

    4. Otherwise, the parent of the command is selected as the target.

  • graphic: Contains an element reference to the graphic element that is copied to the target.

    The same steps for element reference resolution apply, excluding 3 and 4.

  • lookup: Specifies a strategy for looking up a graphic to insert.

    This is a comma-delimited list, order-sensitive, with the following possibilities. Each strategy can have a drawing identifier, specified as strategy?drawing.

    • element: Retrieve a drawing from the element being laid out.

    • class: Retrieve a drawing from the class of the element being laid out.

    • bind: Use the graphic specified on the bind command.

    • icon: Try to bind in the large icon of the source.

    • smallicon: Bind in the small icon of the source.

    • url(urlIdentifier): Use the graphic reachable by the url.

  • source: Designates the source of element information to copy.

    Allowable values are:

    • children: All NAM and ORG children of the element.

    • nam: All NAM children.

    • org: All ORG children.

    • element: The nearest single element DName.

    • properties: The properties of the current element.

    • clipart: Names a clipart object to introduce into the diagram. This is normally used only by the UI while dragging clipart into the drawing.

    • [future] offers: The service level offers an element participates in.

  • classFilter: A regular expression that must match against the element class name of the sources.

    If you want to match against host or router, you might enter host|router.

  • nameFilter: A regular expression used to filter the full names of the sources.

    For elements, it filters the DNames. For properties, it filters the property names.

  • scriptFilter: You can provide a NOC script that receives element, DName, and so forth as variables.

    Return True if the element should be included, and False if it should not. Any other return value is considered to be False.

  • unplaced: Provides a means of laying out elements that are not placed within the current drawing.

    You can set it to the following values:

    • layout: Shows elements that are not handled by the current layout command.

    • drawing: Shows elements that are not placed anywhere else in the current drawing.

  • resize: Resizes the graphic.

  • transform: Designates a transform that is applied to each of the cloned visual elements.

    This is useful for applying a uniform scaling across children, or for offsets.

  • source‑port: When connecting, use this port as the default source point for connection lines.

    Defaults to South.

    If a top-to-bottom graph is being laid out, the source port is South and the default dest-port is North.

  • dest‑port: When connecting, use this port as the default destination.

B.2.2 Template Subcommands

The following template subcommands are available:

  • bindfilter: Filters out elements based on an expression.

    This can be used, for example, to exclude child elements that are not critical.

  • bind:sort: Designates a sort ordering for child elements.

    This can be used to sort on child element name.

B.2.3 Layout Bind Commands

The following layout bind commands are available:

  • bind:templates: This is the core bind:templates command.

    Each of the other commands listed here is transformed into a bind:templates command, internally.

  • bind:children: Equivalent to bind:templates with source=children (all NAM and ORG children).

  • bind:org: Equivalent to bind:templates with source=org (ORG children).

  • bind:nam: Equivalent to bind:templates with source=nam (NAM children).

  • bind:element: Equivalent to bind:templates with source=element (binds self, the nearest scoped object).

  • bind:link: Use link objects to direct connections within the current child/layout groupings.

  • bind:properties: Equivalent to bind:templates with source=properties (current object’s properties).

B.2.4 Layout Target Element Attributes

Elements that are siblings of the bind:templates command are eligible for layout. Certain attributes allow further control of this process. They are as follows:

  • bind:group: A given layout can be performed with respect to a group of child objects.

    Only those child objects tagged with the specified group are included in the layout. This allows multiple layouts to be performed on a parent object, if that is desired. It also provides an easy mechanism to exclude elements from a layout (simply assign a different group).

    The bind:group is optional. If the bind:layout command does not specify a group, the default group is assumed.

    All elements that are not tagged with a bind:group attribute are assumed to be part of the default group.

  • bind:container: Designates an element as a possible container for template copies.

    If a bind:templates command does not specify a target, the nearest bind:container to it (if one exists) is selected as the parent object for the newly created copies.

B.2.5 Generated Copy Variables

As each clone element is created, certain additional attribute variables are added to the generated element to make further binding easier to perform. These variables create certain curves and make them available to further binding commands. They can be used to create certain effects that change when an object is cloned along a path or into a container, such as fading out or scaling down.

  • alpha: Linear, from 0.0 to 1.0, evenly spaced and incremented for each child.

  • log: Logarithmic from 0.0 to 1.0, shifting distribution towards end of scale.

  • sigma: S‑curve, distribution toward both ends.