Saxonica - sgml/signature GitHub Wiki

S.O.L.I.D. XSLT 1.0

When designing XSLT code, applying SOLID principles can lead to more maintainable and flexible transformations. Let's explore how each SOLID principle can be relevant in this context:

  • Single Responsibility Principle

    • Ensure that each XSLT template or function has a single responsibility. For example, separate logic for transforming data from logic related to formatting or output.
    • Avoid mixing concerns like data manipulation and presentation within the same template.
  • Open-Closed Principle

    • Design your XSLT code to be open for extension but closed for modification.
    • Use template modes or named templates to allow easy extension without altering existing templates.
  • Liskov Substitution Principle

    • Ensure that any XSLT template or function can be replaced by its subtype (specialized version) without affecting correctness.
    • Follow consistent naming conventions and parameter structures to maintain compatibility.
  • Interface Segregation Principle

    • In XSLT, interfaces are not directly applicable, but you can think of them as abstract templates or common patterns.
    • Avoid creating overly complex templates that try to do too much. Break them down into smaller, focused templates.
  • Dependency Inversion Principle

    • In XSLT, dependencies are typically external data sources (XML files, databases, etc.).
    • Design your XSLT code to depend on abstractions (e.g., XPath expressions) rather than concrete implementations.
    • Use parameters or global variables to inject dependencies.

XSLT 3.0

Installation

Tail Recursion / DVC