For the US Labor Day archive rerun, Daily WTF editor Remy Porter revisits a submission from a reader named Stella, who inherited an XML Schema meant to validate a homegrown query language used inside a travel booking system.

SourceAttributeType grammar (from XSD docs)
source = ( Feature1+Feature2+... ":" )? steps
Feature1 = "local" | "global"
Feature2 = "real" | "virtual" | "ComponentType.all"
Feature3 = "self" | "ancestors" | "descendants" | "Hierarchy.all"
Feature4 = "first" | "last" | "DayAllocation.all"
steps = oneOrMoreNameSteps | zeroOrMoreNameSteps | componentSteps
nameStep = "#" name

The language, called "Source," lets code reference structured booking data through dot-separated paths such as Product.Accommodation.SellingAccom.Unit.SellingUnit, Product.OnewayFlight.BookingClass, Product.ReturnFlight.Inbound, Product.ReturnFlight.Outbound, and Product.Addon.Service.ServiceFeature. Queries can also carry an optional prefix of ordered flags: scope (local or global), component type (real, virtual, or ComponentType.all), hierarchy (self, ancestors, descendants, or Hierarchy.all), and day allocation (first, last, or DayAllocation.all), separated from the path by a colon.

Instead of expressing that grammar through nested XSD types, Stella's predecessor packed the entire rule set into one xs:pattern regular expression, 1,310 characters long, inside an xs:simpleType named SourceAttributeType. Stella had to track down and fix a bug in that expression, describing the debugging process as something that kills "a few little kitties" every time the pattern runs.

The schema does include documentation, in German and English, spelling out the same grammar in readable prose right above the unreadable regex meant to enforce it.