Declarative search the hard way:

Building an SRU-powered Next.js tool for the
National Library of the Netherlands

Valerie Gibson — Drupal & Search Developer

Something about me

Drupal Solr Search AI techniques Vector embeddings Semantic search Next.js SRU

When I started this project...

  • No experience with Next.js
  • No idea how SRU/CQL really worked
  • No documentation of the XML responses

The Challenge

The Royal Library’s SRU endpoint was old, inconsistent, and last but not least: it was undocumented.

  • I had to reverse-engineer the XML structure
  • Responses changed even for similar queries

To give you an idea

This is what the old tool looked like.

What is SRU?

SRU = Search/Retrieve via URL
CQL = Contextual Query Language

It’s a declarative protocol — you describe what you want, not how to get it.


  ?operation=searchRetrieve&query=title all "climate"
        

The Legacy Reality

In Theory In Practice
Elegant and declarative Inconsistent XML
Structured metadata Missing namespaces
Simple queries No wildcard support 😬

Reverse-Engineering the Response

  1. Send a request manually
  2. Inspect the XML response
  3. Guess what each element means
  4. Write a parser
  5. Realize it breaks for another record type 😅

Building the Frontend

  • Next.js (App Router, TypeScript, Turbopack)
  • Direct SRU communication — no API layer
  • Fully declarative browsing of journals, articles, ISSN and NBNs

The design

The navigation

The form

The alphabet results

The article results

Declarative Design

Each interaction is a CQL query – no imperative API logic.

The UI simply renders whatever the request declares.

The Beauty and the Pain

💎 Elegant 🧨 Fragile
Transparent queries Inconsistent responses
No backend needed No validation or schema

AI Assistants to the Rescue

Understanding CQL syntax

Generating parsing code

Debugging strange XML edge cases

AI was my pair programmer 🤖

The Double-Edged Sword

AI accelerated development but also caused new fragility:

  • Hallucinated XML examples
  • Overfitted parsing logic
  • False sense of completion

“AI is great at making you think you’re done.”

The final result

This is what it has become.

Lessons Learned

  • Declarative protocols age gracefully — but not perfectly
  • Documentation matters less than actual data
  • Reverse-engineering teaches structure awareness
  • AI helps — but you still need to read the XML yourself

Reflection

Declarative search isn’t new — SRU proved that years ago.

But with modern web frameworks and AI tooling, it becomes relevant again.

Any questions?

@Declarative Amsterdam 2025