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.
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 = "#" nameThe 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.




Comments
No comments yet — be the first.
Open the discussion
No account or password needed — just enter your e-mail and we’ll send you a one-time sign-in link. First time here? You’re set up automatically.
Your rating will be applied automatically after you sign in.
Check your inbox
We’ve sent a sign-in link to …. Open it on this device — this tab will sign you in automatically.
Nothing arrived? Check your spam folder — and mark the mail as "Not spam" so it lands in your inbox next time.