commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Stefan Heimann <m...@stefanheimann.net>
Subject [Digester] Enhancements, Namespace
Date Sun, 18 Aug 2002 13:31:49 GMT
Hi,

I have rewritten the namespace support of the digester. It's now
possible to match patterns like ``foo:a/bar:b'', where ``foo'' and
``bar'' are prefixed for some registered namespace uris.

This is what I have done:

I have removed the methodes setNamespaceURI(String uri) and
getNamespaceURI from the Rules interface. Instead, I have added
methods to register a namespace prefix and to set a default namespace
uri:

public void registerNamespacePrefix(String prefix, String uri)
public String getNamespacePrefix(String prefix)
public void setDefaultNamespaceUIR(String uri)
public String getDefaultNamespaceURI()

The signature of the match method in the Rules interface has changed:

public List match(QNameList qnames)

QNameList is a list of QNames. I have updated the digester to store
the path of the element reached so far in a QNameList instead of a
String.

I also changed to Rule class by removing the methods that deal with
namespaces. 

The matching behaviour is like the following:

An element A in a pattern matches an element B if

* both A and B have an namespace and the namespace and the local name
  are equal
* A or B does not have a namespace and the local name is equal

I am not sure, if a pattern element with a namespace should match an
element without a namespace, but I have implemented it that way, so
that the matching-behaviour does not change. BTW: all unit tests are
still running!

As you can see, this api is _not_ backward compatible. Especially the
change in the Rule method will break existing code. So I suggest to
make a digester 2.0 or whatever. We could also fix some other
problems:

* Remove all deprecated methods
* Propagate the exceptions thrown in the begin(), body() and end()
  method of a Rule.
* Rename the Rules interface into Matcher. That's what it does. The
  name Rules does not communicate very good, because the classes Rule
  and RuleSet have quiet similar names but different meaning.

There might be some other things to improve...

Bye,
  Stefan


--
To unsubscribe, e-mail:   <mailto:commons-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:commons-dev-help@jakarta.apache.org>


Mime
View raw message