[jdom-interest] jarv filter & jdom

Carlos Pita carlosjosepita at yahoo.com.ar
Thu Mar 31 06:27:28 PST 2005


I need to do relax ng validation. I'm using msv/jarv and jdom.
Simple alternatives are to validate first and then create the
jdom document, or to get sax events or a dom from the jdom
document and then validating.

But jarv also offers a filter which can be put
between the sax reader and the sax content handler. I guess
that this is the best alternative regarding performance (cause
parsing is done only once and there is only one in-memory
representation of the document model). The problem is that
I can't see how to plug this filter into the SAXBuilder
via the public api. There is a protected method that perhaps
could be overridden:

  protected XMLReader createParser();

The following worked for me, but maybe is a little kludgy:
  class FilteredSAXBuilder extends SAXBuilder {

    private VerifierFilter filter = null;
    public void setFilter(VerifierFilter filter) {
        this.filter = filter;
    protected XMLReader createParser() throws JDOMException {
        XMLReader parser = super.createParser();
        return filter;

Another way could be via XMLReaderFactory.
I'm not sure about what to do. Could you give me some advice?

Thank you in advance.

More information about the jdom-interest mailing list