commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simon Kitching <>
Subject Re: matching patterns with or without namespace
Date Thu, 17 Feb 2005 23:56:51 GMT
Hi Allan,

On Thu, 2005-02-17 at 15:51 -0500, Allan Axon wrote:
> I'm trying to use the digester with a rules.xml file. The xml file I am 
> parsing looks like this:
> <?xml version="1.0" encoding="ISO-8859-1" ?>
> <SOAP-ENV:Envelope xmlns:SOAP-ENV ... >
>   <SOAP-ENV:Body>
>     <Ob xmlns:obns=...>
>       <ObProfile>
>         <ObPanel att1=...>
> ....
>     </Ob>
>   </SOAP-ENV:Body>
> </SOAP-ENV:Enveloper>
> My patterns look like this "SOAP-ENV:Envelope/SOAP:Body/Oblix/ObProfile" 
> when digester.setNamesspaceAware(false). Is this the correct pattern?

Yes I think so. 

Of course this is theoretically broken, as it builds in a hard-wired
assumption that namespace "..." is mapped to the prefix "SOAP-ENV", and
namespace "..." is mapped to the prefix "obns". The creator of the
document ought to have the freedom to use any prefix they like (as long
as it maps to the same namespace URI), but patterns wouldn't match. 

However if you know in your environment that the prefix strings will
always be SOAP-ENV and obns then disabling namespaces and matching by
prefixes is a reasonable solution, given digester's limited support for
namespaces (at least in the 1.x series!).

> Could I use the obns with digester.setNamespaceAware(true) and 
> digester.setRuleNamespaceURI(obnsURI) and use a pattern like: 
> Ob/Obprofile/ObPanel even though none to the elements in the body have 
> <obns:Element> forms. Does this mean the obns namespace is not being 
> used or that it applies to everything below the Ob node?

When namespaceAware is true, all namespaces in the input document are
completely ignored for matching purposes - unless setRuleNamespaceURI
has been called, in which case rules added after that only match when
the current xml element being matched is in that namespace.

As Robert's email pointed out, documentation on this is present at:

> When I run my digester I'm trying to test it by running a public method 
> for the ObProfile object and I get a NullPointerException which I assume 
> means that my patterns are not matching correctly in the xml file.

Quite possibly.

You may wish to enable digester's logging output to get more info on
what is happening. See the FAQ for more info:



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

View raw message