Hi Silvain

----- Original Message -----
From: "Silvain Piree" <[EMAIL PROTECTED]>
>
> Hi,
>
> while browsing through the DOM4J sources I encountered the package
> "org.dom4j.rule".
>
> According to the documentation this is a "a Pattern based
> XML rule engine which implements the full XSLT processing
> model while allowing any Action to be fired if a pattern matches.".
>
> That sounds interesting! Does it work?

Of course!  :-)


> Is there any documentation
> how to use this package?


Unfortunately there's not much right now. Probably the best bet is to look
around the test cases at

dom4j/src/test/org/dom4j/rule/

e.g. TestStylesheet.java demonstrates how to create a 'stylesheet' of Rules.
A Rule has a Pattern and an Action. The Action can be anything at all, the
Pattern is an XSLT-style pattern to match some node or nodes.

So its a kind of XSLT engine which allows pluggable actions of any kind.

Here's some example pseudo code...

        final Stylesheet stylesheet = new Stylesheet();

        Pattern pattern = DocumentHelper.createPattern( "foo[@x='123]" );
        Action action = new Action() {
            public void run(Node node) throws Exception {
                // do something!

                // apply any child templates
                stylesheet.applyTemplates(node);
            }
        };
        Rule rule = new Rule( pattern, action );
        stylesheet.addRule( rule );

        ...

        Document document = ...;
        stylesheet.run( document );

James


_________________________________________________________
Do You Yahoo!?
Get your free @yahoo.com address at http://mail.yahoo.com


_______________________________________________
dom4j-user mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/dom4j-user

Reply via email to