Using Catalog Resolvers with scala.XML

If you need to resolve DTDs locally with the scala.xml parser, you should provide a resolveEntity to the XMLLoader adapter:

import org.xml.sax.InputSource
import xml.parsing.{NoBindingFactoryAdapter, FactoryAdapter}
import xml.factory.XMLLoader
import xml.Elem

object ResolvingXML extends XMLLoader[Elem] {
  override def adapter: FactoryAdapter = new NoBindingFactoryAdapter() {
    override def resolveEntity(publicId: String, systemId: String) : InputSource = {
     // use CatalogResolver here
    }
  }
}

// And use...

val xml = ResolvingXML.loadFile(...someplace...)

This works out because NoBindingFactoryAdapter ultimately extends org.xml.sax.helpers.DefaultHandler, and this gives you the default no-op implementations of EntityResolver, DTDHandler, ContentHandler and ErrorHandler.

I figured this out from related questions and answers on Stackoverflow.