>I would vote for this:
>
> class IXPathProcessor(Interface):
>
> def compile(expression):
> "return compiled expression as IXPathExpression"
>
> class IXPathExpression(Interface):
>
> def evaluateString(xmlString, xmlURL, xpath):
> "return result of xpath evaluation as string"
> # doesn't have to be pretty printed
>
> def evaluateDOM(xmlNode, xmlURL, xpath):
> "return a list of DOM nodes matching xpath"
OK Thats done.
> a compiletime notion of whether a particular
> > processor supports feature X ... I guess we just say
> > if IXPathProcessor.isImplementedBy(processor):
> > # try it...
>
> Well, since we're going into the guts of ProcessorChooser anyway, I vote
> for turning ProcessorChooser into ProcessorRegistry (doesn't have to be
> renamed, although I would favour it), which would work similar to my
> GeneratorRegistry.
> It just provides a facility to register processor and query them
> according to certain implementation features. I think we should not
> query for strings like 'xslt', 'xpath', 'dtd', but for interfaces
> (IXSLTProcessor, IXPathProcessor, etc.). That way we solve your issue a)
> right at its root and b) becomes obsolent, because processors register
> themselves (like my object Generators).
I have refactored ProcessorChooser heavily and renamed
it to ProcessorRegistry. However, I am unable to
make it a mirror image of GeneratorRegistry. The
reason is that it does lazy loading. Worse, even.
It can *never* hold an instance of a processor,
because then it would make ZSyncing across
processors impossible. So making Processors register
themselves once at runtime won't work.
So my refactorings don't end up changing much. Basically
I cleaned up the interface and made it more orthogonal,
and changed to using compile() and exec() to eliminate
the explicit calls to specific processors. In the
end, however, I wonder if its really more readable
or maintainable.
If you get a chance, could you take a glance at the
attached code? I think it might be on the borderline
of being over-engineered...
Thanks,
--Craeg
>
> Thoughts?
>
> Philipp
>
>
|