commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: [Digester] assistance - namespace-aware processing (how to write rules for digest)
Date Sun, 11 Dec 2005 01:42:12 GMT
On Sat, 2005-12-10 at 02:23 -0700, Mike Sparr - wrote:
> If I have a document (note the content element referencing external
> namespace):
> <document>
>   <author name="John Doe" />
>   <title>Some name of a document</title>
>   <exerpt>A brief description of a quotable phrase from
> document</exerpt>
>   <content xmlns:myco="">
>     <myco:heading>This is the heading of the document</myco:heading>
>     <myco:sub-heading>This is the sub-heading of the
> document</myco:sub-heading>
>     <myco:body>
>       This is the body content of the document 
>       and I can have some text that references a 
>       term that may require more explaination so 
>       I add a strangeword<myco:footnote symbol="*" expr="refer to user
> guide for more information" /> and this footnote will appear at 
>       the bottom of the document.
>     </myco:body>
>   </content>
> </document>
> I am new to digester but understand I have to write getter/setter
> classes to represent the different elements.  Can someone help with
> writing the rules to digest this?  I would like some flexibility to have
> zero, one or more namespaces declared in my <content> element and the
> digester will "digest" the elements within these.
> For example, this instance uses a namespace and scheme defined by myco,
> but we may want just text with no namespaces, or use
> xmlns:xhtml="" and embed html in the
> document.
> Where do I start?

There are a number of good resources for learning Digester.

There is a list of articles availabel on the wiki:

There is a general overview of digester in the javadoc:

There are also a number of example applications available. They are
included in the source downloads for digester, or can be browsed
directly from the subversion repository:

Note that Digester's support for xml namespaces is quite weak; it was
originally written before namespaces existed and that shows. A rule can
be associated with a namespace; this ensures that the *last* element in
the match path is in the specified namespace. However there is no
control over namespace-matching for the other parts of the path. As am
example, a rule with path "foo/bar/baz" and namespace "urn:ns1" will
only match baz elements in the specified namespace, but foo and bar will
match elements in any namespace. This looks like it will be acceptable
for your purposes though.

Once you have read the available info, I'm happy to answer any specific
questions you may have...



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

View raw message