You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Allan Axon <Al...@ncmail.net> on 2005/02/17 21:51:51 UTC
matching patterns with or without namespace
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?
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 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.
Thanks,
Allan Axon
NC DENR
--
Allan Axon
Technical Services
Information Technology Services
Department of Environment
and Natural Resources
V: 919-715-0367
F: 919-715-0357
Allan.Axon@ncmail.net
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: matching patterns with or without namespace
Posted by Simon Kitching <sk...@apache.org>.
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:
http://jakarta.apache.org/commons/digester/apidocs/org/apache/commons/digester/package-summary.html#doc.Namespace
>
> 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:
http://wiki.apache.org/jakarta-commons/Digester/FAQ
Regards,
Simon
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org
Re: matching patterns with or without namespace
Posted by robert burrell donkin <ro...@blueyonder.co.uk>.
hi allan
please remember to prefix with [digester]. most folks use mail filters
and this thread is in danger of getting lost...
i'd strongly suggest changing the name of this thread as soon as
possible but here something to start you off: there is no answer as to
whether you should set namespace on or off in this case. it's a tradeoff
and the right trade depends on the particulars of the case. see
http://jakarta.apache.org/commons/digester/apidocs/org/apache/commons/digester/package-summary.html#doc.Namespace
for more information.
- robert
On Thu, 2005-02-17 at 20:51, 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?
>
> 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 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.
>
> Thanks,
> Allan Axon
> NC DENR
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org