⭐⭐⭐⭐⭐

XML is a Cheap DSL

Source: unplannedobsolescence.com | Author: (IRS Engineer) | Date: March 13, 2026
XML DSL IRS Tax Declarative

Summary

An engineer from the IRS Tax Withholding Estimator (TWE) project makes the case for XML as a domain-specific language (DSL) for representing complex tax logic. The project is open source and accepting public contributions.

The Problem: Tax Logic is Complex

Tax calculations involve:

  • Conditional logic (if married, use different brackets)
  • Dependencies between values (total tax depends on tentative tax minus credits)
  • Dynamic questioning (only ask if relevant to user's situation)
  • Different types: dollar amounts, booleans, etc.

XML as Declarative DSL

Instead of imperative JavaScript:

<Fact path="/totalOwed"> <Derived> <Subtract> <Minuend> <Dependency path="/totalTax"/> </Minuend> <Subtrahends> <Dependency path="/totalPayments"/> </Subtrahends> </Subtract> </Derived> </Fact>

This describes: totalOwed = totalTax - totalPayments

The XML explicitly models the dependency graph, not execution order.

Why Not Imperative Code?

Problem 1: Execution Order

JavaScript describes a sequence of actions. But tax logic has circular dependencies and conditional inputs.

Problem 2: Dynamic Questions

You can't ask all questions upfront - some questions only make sense based on earlier answers. XML's declarative model naturally handles this.

Problem 3: Auditability

Tax law must be traceable. The XML shows the calculation structure directly.

Key Operators Available

  • <Add>, <Subtract>, <Multiply>
  • <Min>, <Max>, <GreaterOf>
  • <Dependency> - reference other facts
  • <Writable> - user input
  • <Derived> - computed values
  • <Boolean>, <Dollar> - value types

The Fact Graph Engine

TWE uses the "Fact Graph" - a logic engine originally built for IRS Direct File. It:

  • Parses XML to build a dependency graph
  • Evaluates facts in correct order (topological sort)
  • Handles conditional inputs (only ask what's needed)
  • Supports both derived and writable facts

Key Insight

XML is verbose but unambiguous. For complex, regulated domains like taxes:

  • Verbosity → clarity
  • Explicit structure → auditability
  • Declarative → handles dependencies naturally