Java Mailing List Archive

http://www.junlu.com/

Home » Home (12/2007) » JDOM User »

[jdom-interest] jarv filter & jdom

Carlos Pita

2005-03-31


Hi!

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();
    filter.setParent(parser);
    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.
Regards,
Carlos

_______________________________________________
To control your jdom-interest membership:
http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
©2008 junlu.com - Jax Systems, LLC, U.S.A.