# Adding Parameterized Blocks to SBT Files

**URL:** https://discourse.kitware.com/t/adding-parameterized-blocks-to-sbt-files/1013
**Category:** Design
**Created:** [March 28, 2023, 3:37pm UTC](https://discourse.kitware.com/t/adding-parameterized-blocks-to-sbt-files/1013 "2023-03-28T15:37:16Z")
**Posts on this page:** 1
**Showing post:** 4

<div class="post-metadata">

### Author: ![Bob\_Obara](https://discourse.kitware.com/user_avatar/discourse.kitware.com/bob_obara/32/37_2.png) [@Bob\_Obara](https://discourse.kitware.com/u/Bob_Obara)
#### Post date: [June 28, 2023, 8:12pm UTC](https://discourse.kitware.com/t/adding-parameterized-blocks-to-sbt-files/1013/4 "2023-06-28T20:12:34Z")

</div>

So I examined how the XML Parsers worked and came up with the following that shows which methods processes which XML Elements:

### V1 Parser

- processDerivedItemDefinition - this calls processValueDef
  - DiscreteInfo
    - Set of Discrete Elements
      - Structure Elements
        - Set of Item Names
        - Categories Element
          - Sets of Inclusion and Exclusion

  - DefaultValue
  - RangeInfo ← Should range info have block support?

- processValueDef - this calls processItemDef
  - Labels
  - ExpressionType
  - ChildrenDefiniitons

- processItemDef
  - Categories
  - Description Elements

- getCategories
  - set of category elements - currently don’t care about the element name

- process - method explicitly searched for specific elements - would need to be restructured if we wanted to have block support
  - Analyses - set of Analysis Elements
    - Analysis Element - set of category elements

  - AdvanceLevels - set of Advance Level Elements
  - ActiveCategories - set of Category Elements
  - ItemBlocks
  - AssociationRules
  - Definitions
  - Attributes
  - Views

- processDefinition
  - Color Information elements
  - Description Elements
  - Association Information Element
  - ItemDefiniitons

### V2 Parser

- processDefinition - added RootName attribute
- added extensible File and Directory items and defs
- Added extensible MeshEnitity Items
- Added Secure StringItemDefs
- New View parsing done in View namespace

### V3 Parser

- process
  - Configurations
  - Associations

- processDefiniitonInformation
  - Exclusions
  - Prerequisites

- processDefinition
  - Categories
  - Tags

- processAssociationDef - replaces V1 Implementation
- processReferenceIDef - replaces V1 Implementation
  - Accepts
  - Rejects
  - ConditionalInfo

### V4

- process
  - Evaluators

- processDefiniiton
  - AssociationRule
  - DissasociationRule

- processItemDef
  - Tags

### V5

- nothing definition related

### V6

- New Category Format

The main issue is that the parsers work by searching for explicit elements in the XML representation and then processing those elements. In order to put in Block support, we need to _invert_ the control logic so that we iterate over all of the XML child elements and pass them into methods that will determine how they should be processed. If the V(X) Parser implementation does not recognized the element type then it is passed to the V(X-1) implementation.

The iteration method would then explicitly look to see if a Block Instantiation Element is encountered, create the appropriate block of XML elements and then recursively call itself with those elements.

I plan on initially doing this for Definition (so that Blocks could be used for Association Information, and for Value Item Definitions so that Blocks can be used for Discrete Information) but this can be expanded later if there is need.

---

_[View the full topic](https://discourse.kitware.com/t/adding-parameterized-blocks-to-sbt-files/1013)._
