commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Luke Shannon" <lshan...@futurebrand.com>
Subject Digester Quesion
Date Mon, 07 Feb 2005 19:30:06 GMT
Hello All;

I have been successfully processing a series of documents with the following
code:

//thanks to Wendy
public TreeMap digest() throws IOException, SAXException {
  digester = new Digester();
  digester.setValidating(false);
  digester.addObjectCreate("DATA/VERSION", TreeMap.class);
  digester.addCallMethod("DATA/VERSION/ITEM", "put", 2);
  digester.addCallParam("DATA/VERSION/ITEM", 0, "NAME");
  digester.addCallParam("DATA/VERSION/ITEM", 1);
  return (TreeMap)digester.parse(parseMe);

 }

What I end up back is a TreeMap containing the value of the ITEM@name as the
Map key and the value of <ITEM> as the Map value. Things were running
smoothly until I was told today that some <ITEM> contain a size attribute.
Example:

 <ITEM DIR="air3.pdf" HEIGHT="-1" NAME="kcfileupload" SIZE="117960"
STYPE="file" TYPE="upload" WIDTH="1">air3.pdf</ITEM>

In this example I would need the value 117960 as well.

This is where my lack of digester knowledge comes apparent.

My first reaction was to create a pattern to ITEM@size (I have an idea of
how to do this but am not entirely sure) and than append it to the value
that gets used in this line:

digester.addCallParam("DATA/VERSION/ITEM", 1);

Note: I would include a deliminator I could use later to separate the
values. Again I have idea of how I would do this but am not entirely sure.

What I would like to know is, syntaxically is this possible? Is there an
easier way within the Digester API to do this?

Thanks,

Luke



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