Declarative Parser
The Matrix Framework’s declarative parser allows you to define your middleware tree structure using a familiar markup syntax.
Overview
The parser processes markup files to create a hierarchical tree of middleware components.
Example
<TreeGeometry>
<MQTTConnector Name="MQTTConnector" Path="/mqtt">
<JWTAuthorizationComponent Name="JWTAuthorization" Path="/jwt">
<TerminalComponent Name="Terminal" Path="/terminal" />
</JWTAuthorizationComponent>
</MQTTConnector>
</TreeGeometry>Key Features
- Component Creation: Automatically creates and configures components
- Property Setting: Sets component properties from attributes
- Event Binding: Binds event handlers using onEventName attributes
- Tree Building: Constructs the middleware tree hierarchy
Usage
// Parse markup string
const tree = await Parser.parse(markupString);
// Access components
const mqttConnector = tree.findNode("/mqtt");
const terminal = tree.findNode("/mqtt/jwt/terminal");Best Practices
-
Organize Components
- Group related components together
- Use consistent naming conventions
- Maintain clear hierarchy
-
Property Configuration
- Set properties using attributes
- Use data binding where appropriate
- Validate property values
-
Event Handling
- Bind event handlers declaratively
- Keep handler names descriptive
- Consider event propagation