commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Matthijs Wensveen <>
Subject Re: [digester] validating against system dtd?
Date Fri, 19 Sep 2003 06:56:29 GMT
Simon Kitching wrote:

>On Fri, 2003-09-19 at 13:14, Craig R. McClanahan wrote:
>>>Is there a way to validate each namespace separately. Because for each
>>>application we use different xml with similar elements, this would be
>>>very useful. Maybe this is a question for another (more xml specific)
>>>mailing list, at least I couldn't find anything useful on the net.
>>>If the answer includes separating the validation process from the rest
>>>that's fine (maybe even better so I can turn validation on or off).
>>Digester knows how to deal with namespaces, but you need to tell it to do
>>so.  Basically, that means calling setNamespaceAware(true) and then making
>>sure that your rules are associated with the appropriate namespace URi.
>>Examples of this are in the Digester API Javadocs (see the Package
>>Description for the org.apache.commons.digester package)
>>Scroll down to the section on "Namespace Aware Parsing".
>I *think* Matthijs is asking about validating the input against a
>schema, separately from parsing the input with digester.
>While on the topic of Digester namespace-aware pattern-matching, though,
>it should be pointed out that digester's pattern matching is a bit of a
>hack. It *only* allows specifying what namespace the *final* element in
>the pattern is in. Namespaces are ignored for all other elements in the
>digester.addObjectCreate("foo/bar/baz", ...)
>means that the pattern will match:
>* a baz element in the namespace ONLY, when inside
>* a bar element in any namespace or no namespace, when inside
>* a foo element in any namespace or no namespace.
>You cannot control the namespace associated with foo or bar at all.
>This is not "xpath-compliant". However it generally does the job, and
>makes the internal code simpler.
>I've been meaning to submit a doc update to the "Namespace Aware
>Parsing" section to describe this - unless I've misunderstood the code,
You're right Simon. Namespace aware parsing is not really a problem. 
Taking your note about the final element in consideration, I still think 
this would work for me. The problem was (and still is) in de _validation_.
The fact that Digester is a ContentHandler is very useful. Maybe I can 
write my own validator that validates each namespace before it's sent to 

For your interest, I am relying heavily on the pluggable aspect of 
Digester. The first few elements in my config.xml plug RuleSets into the 
Digester at run-time. Who in turn take a part of the rest of config.xml 
as configuration data. This means that very reusable code can be written 
in RuleSets and employed at will at deploy-time.
For example (no namespaces yet in this example):

<?xml version="1.0"?>
    <!-- Digester RuleSets -->
    <digester-ruleset class="PropertiesRuleSet" 
pattern="config/properties" />
    <!-- MailBean example properties -->
    <properties name="">
        <property key="messagetemplate" value="/feedback.txt" />
        <property key="smtpserver" value="XXX" />
        <property key="from" value="XXX" />
        <property key="bcc" value="XXX" />

    <properties name="mailbean.enquete">
        <property key="messagetemplate" value="/enquete.txt" />
        <property key="smtpserver" value="XXX" />
        <property key="to" value="XXX" />

Thanks a lot for your help so far. I will take the validation issue to 
another place (maybe somewhere @


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

View raw message