commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [digester] how to make use of xml:lang?
Date Mon, 20 Oct 2003 20:57:29 GMT
Hi Ricky,

It looks to me like what you need is a Rules class which can match
elements according to the value of specific attributes. None of the
existing Rules classes do this, but it seems reasonable to me. The
pattern syntax could include xpath-like conditions, eg
and only attr elements with an xml:lang attribute matching the specified
value would be considered "matches" for the pattern.

Implementing such a Rules class would be non-trivial, though. As a
simpler solution along the same lines, how about writing a LangRules
class which extends BaseRules (or whichever), and has a match method
  List matches = super.match(...)
  for each rule in matches
    if xml:lang exists, 
       and the attribute value is not the desired language
      remove the element from the match list

I'm not so keen on patching the Digester class itself to look explicitly
for xml:lang attributes. It feels like a hack to me. Of course you can
always modify Digester (or subclass it) for your own use.

Of course if you feel up to implementing a generic Rules class as
described above, then please do!



On Tue, 2003-10-21 at 08:14, Ricky Panaglucci wrote:
> i want some properties set according to given locale. 
> if no lang:xml is specified in a given element,
> its values are taken. if no maching lang:xml is found,
> the element without lang:xml or with lang:xml="en" is
> taken.
> there is a method setSchemaLanguage, but i do not use
> schema.
> the best solution to me is indeed extending Digester,
> hooking into startElement() ... 
> locale: en
> <obj>
>   <attr xml:lang="en" name="foo" value="bar"/> <- take
> this
>   <attr xml:lang="fr" name="foo" value="baz"/>
> </obj>
> <obj>
>   <attr xml:lang="fr" name="foo" value="baz"/>
>   <attr name="foo" value="bar"/>  <- take this
> </obj>
> ricardo

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message