commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Craig R. McClanahan" <craig...@apache.org>
Subject Re: [digester] how to make use of xml:lang?
Date Mon, 20 Oct 2003 22:29:00 GMT
Simon Kitching wrote:

>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?????
>
>  
>

I'd be -1 on trying to make anything in the generic rules dependent 
*solely* on xml:lang, instead of being able to be dependent on some 
other arbitrary attribute.

If it were up to me, I wouldn't build conditionality into the Digester 
rules in the first place -- I'd build it into the object that receives a 
completed object and ignores it if it doesn't want that instance.  But 
that's just me ...

>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
>
>  
>
Craig

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



---------------------------------------------------------------------
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