You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Mark R. Diggory" <md...@latte.harvard.edu> on 2004/02/11 19:52:48 UTC

[configuration][digester] Other XML file formats...

I have an XML config file format I'm trying to read into Configurator or 
Digester which is not the standard format expected (and which I cannot 
change), it looks like:

<Config name="user_config">
     <Variable type="option" key="DEBUG" value="1" />
     <Variable type="option" key="SQUID_DIR_SIZE" value="750" />
     <Variable type="option" key="auto" value="1" />
     <Variable type="option" key="build_all" value="0" />
     <Variable type="option" key="help" value="0" />

which I'd like to get handled as
value = user_config.<type>.<key> or value = user_config.<type>[<key>]

my ultimate goal is to plug it into the tomcat JNDI Resources as to 
attain something more like this in the long run:

Context ctx = new InitialContext();
ctx.lookup("java:comp/env/userconfig/<type>/<key>

Is there a quick way I can get to this format using using digester or 
configuration?

thx,
Mark

-- 
Mark Diggory
Software Developer
Harvard MIT Data Center
http://www.hmdc.harvard.edu

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


Re: [configuration][digester] Other XML file formats...

Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi mark

(sorry this is a little late.)

i don't think that there's anything in the standard digester rules that 
does what you want - but it'd be very easy to create a custom rule 
which would fit the bill.

something like:

public class JNDIRule extends Rule {
	public void begin(String namespace, String name, Attributes attributes)
			throws Exception {
		String type = attributes.getValue("type");
		String key = attribute.getValue("key");

		Context ctx = new InitialContext();
		Object someObject = ctx.lookup("java:comp/env/userconfig/type/key
		...
		do some processing
		...
	]
}

- robert

On 11 Feb 2004, at 18:52, Mark R. Diggory wrote:

> I have an XML config file format I'm trying to read into Configurator 
> or Digester which is not the standard format expected (and which I 
> cannot change), it looks like:
>
> <Config name="user_config">
>     <Variable type="option" key="DEBUG" value="1" />
>     <Variable type="option" key="SQUID_DIR_SIZE" value="750" />
>     <Variable type="option" key="auto" value="1" />
>     <Variable type="option" key="build_all" value="0" />
>     <Variable type="option" key="help" value="0" />
>
> which I'd like to get handled as
> value = user_config.<type>.<key> or value = user_config.<type>[<key>]
>
> my ultimate goal is to plug it into the tomcat JNDI Resources as to 
> attain something more like this in the long run:
>
> Context ctx = new InitialContext();
> ctx.lookup("java:comp/env/userconfig/<type>/<key>
>
> Is there a quick way I can get to this format using using digester or 
> configuration?
>
> thx,
> Mark
>
> -- 
> Mark Diggory
> Software Developer
> Harvard MIT Data Center
> http://www.hmdc.harvard.edu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org
>


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


RE: [configuration][digester] Other XML file formats...

Posted by Eric Pugh <ep...@upstate.com>.
Not that I know of..  It does seem like Configuration needs some sort of
more expressive/pluggable way of doing this..  Some challenges I can see
would be funny rules like type/key/value are all in order..  Versus
type/value/key or something..

A couple people have been asking for xpath type queires...

Eric

> -----Original Message-----
> From: Mark R. Diggory [mailto:mdiggory@latte.harvard.edu]
> Sent: Wednesday, February 11, 2004 7:53 PM
> To: Jakarta Commons Developers List
> Subject: [configuration][digester] Other XML file formats...
>
>
> I have an XML config file format I'm trying to read into
> Configurator or
> Digester which is not the standard format expected (and which
> I cannot
> change), it looks like:
>
> <Config name="user_config">
>      <Variable type="option" key="DEBUG" value="1" />
>      <Variable type="option" key="SQUID_DIR_SIZE" value="750" />
>      <Variable type="option" key="auto" value="1" />
>      <Variable type="option" key="build_all" value="0" />
>      <Variable type="option" key="help" value="0" />
>
> which I'd like to get handled as
> value = user_config.<type>.<key> or value = user_config.<type>[<key>]
>
> my ultimate goal is to plug it into the tomcat JNDI Resources as to
> attain something more like this in the long run:
>
> Context ctx = new InitialContext();
> ctx.lookup("java:comp/env/userconfig/<type>/<key>
>
> Is there a quick way I can get to this format using using digester or
> configuration?
>
> thx,
> Mark
>
> --
> Mark Diggory
> Software Developer
> Harvard MIT Data Center
> http://www.hmdc.harvard.edu
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-dev-help@jakarta.apache.org


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