I'm new using xml-dbms. I'm going to write an
application using xml-dbms. Is there an API or method
to set the filter instead of using filters.dtd ?
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
See the package org.xmlmiddlware.xmldbms.filters. The classes you will
probably need are FilterBase, FilterSet, RootFilter, TableFilter,
ResultSetFilter, RelatedTableFilter, and FilterConditions. These classes
are generally used internally, so they're not that heavily documented.
If you have questions about their use, look at FilterCompiler, which
reads a filter document and creates a FilterSet object using these
classes. The classes also correspond fairly closely to the elements and
attributes in the filter language, so learning that will help you use them.
A word of caution:
Filter, action, and map documents are all compiled into a set of
internal objects. The top level objects (FilterSet, Actions, XMLDBMSMap)
are designed for your application to use directly, such as when
calling DOMToDBMS or DBMSToDOM. However, your application doesn't need
to do anything but pass them in as opaque objects representing a
particular filter, action, or map document.
It is possible to build these objects directly, just as the various
compilers do. However, there seems little reason to do this. It is far
easier to write a document, compile it, and then use the resulting
object in your application. Furthermore, the compiled object can be
reused. For example, you can use a particular XMLDBMSMap object to make
many data transfers that all use the same mapping.
And while there is probably a performance penalty for compiling
documents into objects (as opposed to building those objects yourself),
it is utterly insignificant compared to the cost of the database calls
made elsewhere in XML-DBMS. In exchange, you have a much higher
development cost, as you are writing code to build these objects instead
of writing a simple XML document.
A final reason to avoid creating these objects directly is that it is
very easy to shoot yourself in the foot, as the methods on them are more
forgiving of abuse than those designed for more public use, such as
those on DOMToDBMS or Transfer. For example, you can create a FilterSet
object that contains no RootFilters or ResultSetFilters and pass this to
DBMSToDOM. Although I have not looked, the code in DBMSToDOM probably
doesn't check for this condition and will likely fail (such as with a
null pointer exception) when you do this.
That said, one good reason to build these objects directly is if you are
writing an editor for creating XML-DBMS mappings, filters, and actions.
Tommy Fan wrote:
> I'm new using xml-dbms. I'm going to write an
> application using xml-dbms. Is there an API or method
> to set the filter instead of using filters.dtd ?