commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <si...@ecnetwork.co.nz>
Subject Re: [digester] how to make use of xml:lang?
Date Mon, 20 Oct 2003 22:08:51 GMT
On Tue, 2003-10-21 at 10:57, Craig R. McClanahan wrote:

> But you could certainly supply your own Rule (no trailing "s") 
> implementation whose begin() method checked the Attributes that are 
> passed to see which (if any) xml:lang attribute was set.
> 
> Craig

Hmm .. so

 digester.addRule ( 
    "obj/attr",
    new LangFilterRule("en",
      new CallMethodRule(....));

 digester.addRule ( 
    "obj/attr",
    new LangFilterRule("en",
      new CallParamRule(....));

 digester.addRule ( 
    "obj/attr",
    new LangFilterRule("fr",
      new CallMethodRule(....));

 digester.addRule ( 
    "obj/attr",
    new LangFilterRule("fr",
      new CallParamRule(....));

Looks pretty cumbersome to me. Doable, but cumbersome.

Depends how many language-sensitive rules there are, I guess.

It would certainly be nicer to say:
  digester.setLanguage("fr")
or
  digester.getRules().setLanguage("fr")


Hmm... maybe the solution is instead to write a SAX filter that filters
out any elements with undesirable lang settings?????

Ricky: note that Digester implements org.xml.sax.ContentHandler, ie you
can create a SAX parser object yourself and set a Digester instance as
the content handler for that parser (this is all Digester's parse method
does internally). So you could:
(a) create a SAXParser instance
(b) create an org.xml.sax.XMLFilter instance which removes all undesired
elements and passes the remainder to the Digester instance.


Hope this helps,

Simon


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Mime
View raw message