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)
> 
>   http://jakarta.apache.org/commons/digester/api/
> 
> 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
pattern.

eg
digester.setNamespaceUri("http://acme.com";);
digester.addObjectCreate("foo/bar/baz", ...)

means that the pattern will match:
* a baz element in the acme.com 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,
Craig??

Regards,

Simon



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to