[jboss-svn-commits] JBL Code SVN: r17140 - in labs/jbossrules/trunk/drools-compiler/src/main/java: rules and 1 other directory.

jboss-svn-commits at lists.jboss.org jboss-svn-commits at lists.jboss.org
Sun Dec 9 22:37:32 EST 2007


Author: mark.proctor at jboss.com
Date: 2007-12-09 22:37:32 -0500 (Sun, 09 Dec 2007)
New Revision: 17140

Added:
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHelperHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AndHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/CollectHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/EvalHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExistsHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExpressionHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldBindingHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldConstraintHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ForallHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FromHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FunctionHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/LiteralRestrictionHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/NotHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/OrHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PackageHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PatternHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PredicateHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QualifiedIdentifierRestrictionHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QueryHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RestrictionConnectiveHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ReturnValueRestrictionHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RuleHandler.java
   labs/jbossrules/trunk/drools-compiler/src/main/java/rules/VariableRestrictionsHandler.java
Log:
JBRULES-1375 Create initial ePDL language parser implementation

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/AccumulateHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,90 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author fernandomeyer
+ */
+public class AccumulateHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public AccumulateHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+
+            this.validParents.add( FromDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final AccumulateDescr accumulateDesrc = new AccumulateDescr();
+        return accumulateDesrc;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+        final AccumulateDescr accumulateDescr = (AccumulateDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent.getClass().getName().equals( FromDescr.class.getName() ) ) {
+            final PatternDescr result = (PatternDescr) xmlPackageReader.getParent( 1 );
+            result.setSource( accumulateDescr );
+
+        } else if ( parent instanceof ConditionalElementDescr ) {
+            final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
+            parentDescr.addDescr( accumulateDescr );
+        }
+
+        return accumulateDescr;
+    }
+
+    public Class generateNodeFor() {
+        return AccumulateDescr.class;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHelperHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/AccumulateHelperHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHelperHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AccumulateHelperHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,105 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author fernandomeyer
+ */
+
+public class AccumulateHelperHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public AccumulateHelperHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AccumulateDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( BaseDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        return new BaseDescr();
+    }    
+    
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final String expression = config.getText();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        final AccumulateDescr accumulate = (AccumulateDescr) parent;
+
+        if ( localName.equals( "init" ) ) {
+            emptyContentCheck( localName, expression, xmlPackageReader );
+            accumulate.setInitCode( expression.trim() );
+        } else if ( localName.equals( "action" ) ) {  
+            emptyContentCheck( localName, expression, xmlPackageReader );
+            accumulate.setActionCode( expression.trim() );
+        } else if ( localName.equals( "result" ) ) { 
+            emptyContentCheck( localName, expression, xmlPackageReader );
+            accumulate.setResultCode( expression.trim() );
+        } else if ( localName.equals( "reverse" ) ) {
+            emptyContentCheck( localName, expression, xmlPackageReader );
+            accumulate.setReverseCode( expression.trim() );
+        } else if ( localName.equals( "external-function" ) ) {
+            accumulate.setExternalFunction( true );
+            accumulate.setFunctionIdentifier( config.getAttribute( "evaluator" ) );
+            accumulate.setExpression( config.getAttribute( "expression" ) );
+        }
+
+        return null;
+    }
+
+    public Class generateNodeFor() {
+        return BaseDescr.class;
+    }    
+
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AndHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/AndHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AndHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/AndHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,111 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.MultiPatternDestinationDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class AndHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public AndHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( QueryDescr.class );
+            this.validParents.add( RuleDescr.class );
+            this.validParents.add( OrDescr.class );
+            this.validParents.add( LiteralRestrictionHandler.class );
+            this.validParents.add( AccumulateDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final AndDescr andDescr = new AndDescr();
+
+        return andDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final AndDescr andDescr = (AndDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof RuleDescr || parent instanceof QueryDescr ) {
+            final RuleDescr ruleDescr = (RuleDescr) parent;
+            ruleDescr.setLhs( andDescr );
+        } else if ( parent instanceof MultiPatternDestinationDescr) {
+        	final MultiPatternDestinationDescr mpDescr = (MultiPatternDestinationDescr) parent;
+        	mpDescr.setInput(andDescr);        	
+        } else if ( parent instanceof ConditionalElementDescr ) {
+            final ConditionalElementDescr ceDescr = (ConditionalElementDescr) parent;
+            ceDescr.addDescr( andDescr );
+        }
+
+        return andDescr;
+    }
+
+    public Class generateNodeFor() {
+        return AndDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/CollectHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/CollectHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/CollectHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/CollectHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,90 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.CollectDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author fernandomeyer
+ *
+ */
+public class CollectHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public CollectHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+
+            this.validParents.add( FromDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final CollectDescr collectDescr = new CollectDescr();
+        return collectDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+        final CollectDescr collectDescr = (CollectDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent.getClass().getName().equals( FromDescr.class.getName() ) ) {
+            final PatternDescr resultPattern = (PatternDescr) xmlPackageReader.getParent( 1 );
+            resultPattern.setSource( collectDescr );
+        } else if ( parent instanceof ConditionalElementDescr ) {
+            final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
+            parentDescr.addDescr( collectDescr );
+        }
+
+        return collectDescr;
+    }
+
+    public Class generateNodeFor() {
+        return CollectDescr.class;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/EvalHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/EvalHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/EvalHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/EvalHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,102 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class EvalHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public EvalHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AndDescr.class );
+            this.validParents.add( OrDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final EvalDescr evalDescr = new EvalDescr();
+
+        return evalDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final EvalDescr evalDescr = (EvalDescr) xmlPackageReader.getCurrent();
+
+        final String expression = config.getText();
+
+        emptyContentCheck( localName, expression, xmlPackageReader );
+
+        evalDescr.setContent( expression );
+
+        final ConditionalElementDescr parentDescr = (ConditionalElementDescr) xmlPackageReader.getParent();
+        parentDescr.addDescr( evalDescr );
+
+        return evalDescr;
+    }
+
+    public Class generateNodeFor() {
+        return EvalDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExistsHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/ExistsHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExistsHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExistsHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,101 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class ExistsHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public ExistsHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AndDescr.class );
+            this.validParents.add( OrDescr.class );
+            this.validParents.add( NotDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final ExistsDescr existsDescr = new ExistsDescr();
+
+        return existsDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final ExistsDescr existsDescr = (ExistsDescr) xmlPackageReader.getCurrent();
+
+        if ( (existsDescr.getDescrs().size() != 1) && (existsDescr.getDescrs().get( 0 ).getClass() != PatternDescr.class) ) {
+            throw new SAXParseException( "<exists> can only have a single <pattern...> as a child element",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        final ConditionalElementDescr parentDescr = (ConditionalElementDescr) xmlPackageReader.getParent();
+        parentDescr.addDescr( existsDescr );
+
+        return existsDescr;
+    }
+
+    public Class generateNodeFor() {
+        return ExistsDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExpressionHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/ExpressionHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExpressionHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ExpressionHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,106 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.antlr.runtime.ANTLRStringStream;
+import org.antlr.runtime.CharStream;
+import org.antlr.runtime.CommonTokenStream;
+import org.antlr.runtime.RecognitionException;
+import org.antlr.runtime.TokenStream;
+import org.drools.lang.DRLLexer;
+import org.drools.lang.DRLParser;
+import org.drools.lang.descr.BaseDescr;
+import org.drools.lang.descr.DeclarativeInvokerDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author fernandomeyer
+ */
+
+public class ExpressionHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public ExpressionHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( FromHandler.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( BaseDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Class generateNodeFor() {
+        return BaseDescr.class;
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        return new BaseDescr();
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final String expression = config.getText();
+        
+        emptyContentCheck( localName, expression, xmlPackageReader );
+
+        final Object parent = xmlPackageReader.getParent();
+
+        final FromDescr fromSource = (FromDescr) parent;
+        final CharStream charStream = new ANTLRStringStream( expression.trim() );
+        final DRLLexer lexer = new DRLLexer( charStream );
+        final TokenStream tokenStream = new CommonTokenStream( lexer );
+        final DRLParser parser = new DRLParser( tokenStream );
+
+        try {
+            final DeclarativeInvokerDescr declarativeInvoker = parser.from_source( fromSource );
+            fromSource.setDataSource( declarativeInvoker );
+        } catch ( final RecognitionException e ) {
+            throw new SAXParseException( "<" + localName + "> must have a valid expression content ",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        return null;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldBindingHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/FieldBindingHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldBindingHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldBindingHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,91 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ */
+public class FieldBindingHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public FieldBindingHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PatternDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FieldConstraintDescr.class );
+            this.validPeers.add( PredicateDescr.class );
+            this.validPeers.add( FieldBindingDescr.class );
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        
+        final String identifier = attrs.getValue( "identifier" );
+        final String fieldName = attrs.getValue( "field-name" );
+        
+        emptyAttributeCheck( localName, "identifier", identifier, xmlPackageReader );        
+        emptyAttributeCheck( localName, "fieldName", fieldName, xmlPackageReader );
+
+        final FieldBindingDescr fieldBindingDescr = new FieldBindingDescr( fieldName,
+                                                                           identifier );
+
+        return fieldBindingDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final FieldBindingDescr fieldBindingDescr = (FieldBindingDescr) xmlPackageReader.getCurrent();
+
+        final PatternDescr patternDescr = (PatternDescr) xmlPackageReader.getParent( );
+
+        patternDescr.addConstraint( fieldBindingDescr );
+
+        return fieldBindingDescr;
+    }
+
+    public Class generateNodeFor() {
+        return FieldBindingDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldConstraintHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/FieldConstraintHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldConstraintHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FieldConstraintHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,108 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class FieldConstraintHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public FieldConstraintHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PatternDescr.class );
+            this.validParents.add( AndDescr.class );
+            this.validParents.add( OrDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FieldConstraintDescr.class );
+            this.validPeers.add( PredicateDescr.class );
+            this.validPeers.add( FieldBindingDescr.class );
+
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String fieldName = attrs.getValue( "field-name" );
+        
+        emptyAttributeCheck( localName, "field-name", fieldName, xmlPackageReader );
+
+        final FieldConstraintDescr fieldConstraint = new FieldConstraintDescr( fieldName );
+
+        return fieldConstraint;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) xmlPackageReader.getCurrent();
+        
+        final Object parent = xmlPackageReader.getParent( );
+
+        if ( parent instanceof PatternDescr ) {
+            final PatternDescr patternDescr = (PatternDescr) parent;
+            patternDescr.addConstraint( fieldConstraintDescr );
+        } else if ( parent instanceof ConditionalElementDescr ) {
+            final ConditionalElementDescr ceDescr = (ConditionalElementDescr) parent;
+            final FieldConstraintDescr field = (FieldConstraintDescr) xmlPackageReader.getCurrent();
+            ceDescr.addOrMerge( field );
+        }
+
+        return fieldConstraintDescr;
+    }
+
+    public Class generateNodeFor() {
+        return FieldConstraintDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ForallHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/ForallHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ForallHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ForallHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,109 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author fernandomeyer
+ *
+ */
+public class ForallHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public ForallHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AndDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+    
+
+    /* (non-Javadoc)
+     * @see org.drools.xml.Handler#start(java.lang.String, java.lang.String, org.xml.sax.Attributes)
+     */
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        xmlPackageReader.startConfiguration( localName,
+                                             attrs );
+
+        final ForallDescr forallDescr = new ForallDescr();
+
+        return forallDescr;
+    }    
+
+    /* (non-Javadoc)
+     * @see org.drools.xml.Handler#end(java.lang.String, java.lang.String)
+     */
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final ForallDescr forallDescr = (ForallDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
+        parentDescr.addDescr( forallDescr );
+
+        return null;
+    }
+
+    /* (non-Javadoc)
+     * @see org.drools.xml.Handler#generateNodeFor()
+     */
+    public Class generateNodeFor() {
+        return ForallDescr.class;
+    }
+
+
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FromHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/FromHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FromHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FromHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,91 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.FromDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author fernandomeyer
+ *
+ */
+public class FromHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public FromHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PatternDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FieldConstraintDescr.class );
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final FromDescr fromDesctiptor = new FromDescr();
+        return fromDesctiptor;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final FromDescr fromDescr = (FromDescr) xmlPackageReader.getCurrent();
+
+        Object parent = xmlPackageReader.getParent();
+
+        final PatternDescr patternDescr = (PatternDescr) parent;
+
+        final ConditionalElementDescr parentDescr = (ConditionalElementDescr)  xmlPackageReader.getParent( 1 );
+
+        if ( (config.getChild( "expression" ) != null) ) {
+            patternDescr.setSource( fromDescr );    
+        }
+
+        return fromDescr;
+    }
+
+    public Class generateNodeFor() {
+        return FromDescr.class;
+    }
+
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FunctionHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/FunctionHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FunctionHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/FunctionHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,114 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class FunctionHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public FunctionHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PackageDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FunctionDescr.class );
+            this.validPeers.add( RuleDescr.class );
+            this.validPeers.add( QueryDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                             attrs );
+        final String name = attrs.getValue( "name" );
+        final String returnType = attrs.getValue( "return-type" );
+        
+        emptyAttributeCheck( localName, "name", name, xmlPackageReader );
+        emptyAttributeCheck( localName, "return-type", returnType, xmlPackageReader );
+
+        final FunctionDescr functionDescr = new FunctionDescr( name,
+                                                               returnType );
+        
+        return functionDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        FunctionDescr functionDescr = ( FunctionDescr ) xmlPackageReader.getCurrent();
+
+        final Configuration[] parameters = config.getChildren( "parameter" );
+
+        for ( int i = 0, length = parameters.length; i < length; i++ ) {
+            final String identifier = parameters[i].getAttribute( "identifier" );      
+            final String type = parameters[i].getAttribute( "type" );
+            
+            emptyAttributeCheck("parameter", "identifier", identifier, xmlPackageReader);                  
+            emptyAttributeCheck("parameter", "type", type, xmlPackageReader);
+            
+            functionDescr.addParameter( type,
+                                        identifier );
+        }
+
+        // we allow empty, "", bodies - but make sure that we atleast have a body element
+        final Configuration body = config.getChild( "body" );
+        if ( body == null ) {
+            throw new SAXParseException( "function must have a <body>",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        functionDescr.setText( body.getText() );
+
+        final PackageDescr packageDescr = (PackageDescr) xmlPackageReader.getData();
+
+        packageDescr.addFunction( functionDescr );
+
+        return functionDescr;
+    }
+
+    public Class generateNodeFor() {
+        return FunctionDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/LiteralRestrictionHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/LiteralRestrictionHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/LiteralRestrictionHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/LiteralRestrictionHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,104 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.QualifiedIdentifierRestrictionDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * @author fmeyer
+ * 
+ */
+public class LiteralRestrictionHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public LiteralRestrictionHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( FieldConstraintDescr.class );
+            this.validParents.add( RestrictionConnectiveDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.validPeers.add( LiteralRestrictionDescr.class );
+            this.validPeers.add( ReturnValueRestrictionDescr.class );
+            this.validPeers.add( VariableRestrictionDescr.class );
+            this.validPeers.add( RestrictionConnectiveDescr.class );
+            this.validPeers.add( QualifiedIdentifierRestrictionDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String evaluator = attrs.getValue( "evaluator" );
+        emptyAttributeCheck( localName, "evaluator", evaluator, xmlPackageReader );
+
+        final String text = attrs.getValue( "value" );
+
+        final LiteralRestrictionDescr literalDescr = new LiteralRestrictionDescr( evaluator,
+                                                                                  text );
+
+        return literalDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final LiteralRestrictionDescr literalDescr = (LiteralRestrictionDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof FieldConstraintDescr ) {
+            final FieldConstraintDescr fieldConstriantDescr = (FieldConstraintDescr) parent;
+            fieldConstriantDescr.addRestriction( literalDescr );
+        } else if ( parent instanceof RestrictionConnectiveDescr ) {
+            final RestrictionConnectiveDescr restrictionDescr = (RestrictionConnectiveDescr) parent;
+            restrictionDescr.addRestriction( literalDescr );
+        }
+        return literalDescr;
+    }
+
+    public Class generateNodeFor() {
+        return LiteralRestrictionDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/NotHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/NotHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/NotHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/NotHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,100 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class NotHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public NotHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AndDescr.class );
+            this.validParents.add( OrDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final NotDescr notDescr = new NotDescr();
+
+        return notDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final NotDescr notDescr = (NotDescr) xmlPackageReader.getCurrent();
+
+        if ( (notDescr.getDescrs().size() != 1) && (notDescr.getDescrs().get( 0 ).getClass() != PatternDescr.class) ) {
+            throw new SAXParseException( "<not> can only have a single <pattern...> as a child element",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        final ConditionalElementDescr parentDescr = (ConditionalElementDescr) xmlPackageReader.getParent();
+        parentDescr.addDescr( notDescr );
+
+        return null;
+    }
+
+    public Class generateNodeFor() {
+        return NotDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/OrHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/OrHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/OrHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/OrHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,100 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author mproctor
+ */
+public class OrHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public OrHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AndDescr.class );
+            this.validParents.add( PatternDescr.class );
+            this.validParents.add( AccumulateDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final OrDescr orDescr = new OrDescr();
+
+        return orDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final OrDescr orDescr = (OrDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof ConditionalElementDescr ) {
+            final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
+            parentDescr.addDescr( orDescr );
+        } else if ( parent instanceof PatternDescr ) {
+            final PatternDescr parentDescr = (PatternDescr) parent;
+            parentDescr.addConstraint( orDescr );
+        }
+
+        return orDescr;
+    }
+
+    public Class generateNodeFor() {
+        return OrDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PackageHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PackageHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PackageHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PackageHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,135 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+
+import org.drools.lang.descr.FunctionImportDescr;
+import org.drools.lang.descr.GlobalDescr;
+import org.drools.lang.descr.ImportDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class PackageHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public PackageHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( null );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String ruleSetName = attrs.getValue( "name" );
+
+        if ( ruleSetName == null || ruleSetName.trim().equals( "" ) ) {
+            throw new SAXParseException( "<package> requires a 'name' attribute",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        final PackageDescr packageDescr = new PackageDescr( ruleSetName.trim() );
+
+        xmlPackageReader.setData( packageDescr );
+        return packageDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final PackageDescr packageDescr = ( PackageDescr ) xmlPackageReader.getData();
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final Configuration[] imports = config.getChildren( "import" );
+
+        for ( int i = 0, length = imports.length; i < length; i++ ) {
+            final String importEntry = imports[i].getAttribute( "name" );
+
+            if ( importEntry == null || importEntry.trim().equals( "" ) ) {
+                throw new SAXParseException( "<import> cannot be blank",
+                                             xmlPackageReader.getLocator() );
+            }
+            packageDescr.addImport( new ImportDescr( importEntry ) );
+        }
+        
+        final Configuration[] importfunctions = config.getChildren( "importfunction" );
+
+        for ( int i = 0, length = importfunctions.length; i < length; i++ ) {
+            final String importfunctionEntry = importfunctions[i].getAttribute( "name" );
+
+            if ( importfunctionEntry == null || importfunctionEntry.trim().equals( "" ) ) {
+                throw new SAXParseException( "<importfunction> cannot be blank",
+                                             xmlPackageReader.getLocator() );
+            }
+            
+            FunctionImportDescr funcdescr = new FunctionImportDescr();
+            funcdescr.setTarget( importfunctionEntry );
+            
+            packageDescr.addFunctionImport(funcdescr);
+        }
+        
+
+        final Configuration[] globals = config.getChildren( "global" );
+
+        for ( int i = 0, length = globals.length; i < length; i++ ) {
+            final String identifier = globals[i].getAttribute( "identifier" );
+
+            if ( identifier == null || identifier.trim().equals( "" ) ) {
+                throw new SAXParseException( "<global> must have an identifier",
+                                             xmlPackageReader.getLocator() );
+            }
+
+            final String type = globals[i].getAttribute( "type" );
+            if ( type == null || type.trim().equals( "" ) ) {
+                throw new SAXParseException( "<global> must have specify a type",
+                                             xmlPackageReader.getLocator() );
+            }
+            final GlobalDescr global = new GlobalDescr( identifier,
+                                                        type );
+            packageDescr.addGlobal( global );
+        }
+
+        return packageDescr;
+    }
+
+    public Class generateNodeFor() {
+        return PackageDescr.class;
+    }
+}

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PatternHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PatternHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PatternHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PatternHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,125 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.AccumulateDescr;
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.CollectDescr;
+import org.drools.lang.descr.ConditionalElementDescr;
+import org.drools.lang.descr.EvalDescr;
+import org.drools.lang.descr.ExistsDescr;
+import org.drools.lang.descr.ForallDescr;
+import org.drools.lang.descr.NotDescr;
+import org.drools.lang.descr.OrDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.PatternDestinationDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class PatternHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public PatternHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( AndDescr.class );
+            this.validParents.add( OrDescr.class );
+            this.validParents.add( NotDescr.class );
+            this.validParents.add( ExistsDescr.class );
+            this.validParents.add( CollectDescr.class );
+            this.validParents.add( ForallDescr.class );
+            this.validParents.add( AccumulateDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( AndDescr.class );
+            this.validPeers.add( OrDescr.class );
+            this.validPeers.add( NotDescr.class );
+            this.validPeers.add( ExistsDescr.class );
+            this.validPeers.add( EvalDescr.class );
+            this.validPeers.add( PatternDescr.class );
+            this.validPeers.add( ForallDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String objectType = attrs.getValue( "object-type" );
+
+        if ( objectType == null || objectType.trim().equals( "" ) ) {
+            throw new SAXParseException( "<pattern> requires an 'object-type' attribute",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        PatternDescr patternDescr = null;
+
+        final String identifier = attrs.getValue( "identifier" );
+        if ( identifier == null || identifier.trim().equals( "" ) ) {
+            patternDescr = new PatternDescr( objectType );
+        } else {
+            patternDescr = new PatternDescr( objectType,
+                                             identifier );
+        }
+
+        return patternDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+
+        final Configuration config = xmlPackageReader.endConfiguration();
+        final PatternDescr patternDescr = (PatternDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof PatternDestinationDescr ) {
+            final PatternDestinationDescr parentDescr = (PatternDestinationDescr) parent;
+            parentDescr.setInputPattern( patternDescr );
+        } else {
+            final ConditionalElementDescr parentDescr = (ConditionalElementDescr) parent;
+            parentDescr.addDescr( patternDescr );
+        }
+        return patternDescr;
+    }
+
+    public Class generateNodeFor() {
+        return PatternDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PredicateHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/PredicateHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PredicateHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/PredicateHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,96 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldBindingDescr;
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.PatternDescr;
+import org.drools.lang.descr.PredicateDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class PredicateHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public PredicateHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PatternDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FieldConstraintDescr.class );
+            this.validPeers.add( PredicateDescr.class );
+            this.validPeers.add( FieldBindingDescr.class );
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final PredicateDescr predicateDescr = new PredicateDescr();
+
+        return predicateDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final PredicateDescr predicateDescr = (PredicateDescr) xmlPackageReader.getCurrent();
+
+        final String expression = config.getText();
+
+        if ( expression == null || expression.trim().equals( "" ) ) {
+            throw new SAXParseException( "<predicate> must have some content",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        predicateDescr.setContent( expression );
+
+        final PatternDescr patternDescr = (PatternDescr) xmlPackageReader.getParent();
+
+        patternDescr.addConstraint( predicateDescr );
+
+        return predicateDescr;
+    }
+
+    public Class generateNodeFor() {
+        return PredicateDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QualifiedIdentifierRestrictionHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/QualifiedIdentifierRestrictionHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QualifiedIdentifierRestrictionHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QualifiedIdentifierRestrictionHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,107 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.QualifiedIdentifierRestrictionDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author fmeyer
+ */
+
+public class QualifiedIdentifierRestrictionHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public QualifiedIdentifierRestrictionHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( FieldConstraintDescr.class );
+            this.validParents.add( RestrictionConnectiveDescr.class );
+
+            this.validPeers = new HashSet();
+
+            this.validPeers.add( null );
+            this.validPeers.add( LiteralRestrictionDescr.class );
+            this.validPeers.add( ReturnValueRestrictionDescr.class );
+            this.validPeers.add( VariableRestrictionDescr.class );
+            this.validPeers.add( RestrictionConnectiveDescr.class );
+            this.validPeers.add( QualifiedIdentifierRestrictionDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String evaluator = attrs.getValue( "evaluator" );
+        emptyAttributeCheck( localName, "evaluator", evaluator, xmlPackageReader );
+
+        final QualifiedIdentifierRestrictionDescr qualifiedIdentifierRestricionDescr = new QualifiedIdentifierRestrictionDescr( evaluator,
+                                                                                                                                null );
+
+        return qualifiedIdentifierRestricionDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final QualifiedIdentifierRestrictionDescr qualifiedIdentifierRestricionDescr = (QualifiedIdentifierRestrictionDescr) xmlPackageReader.getCurrent();
+
+        final String expression = config.getText();
+
+        emptyContentCheck( localName, expression, xmlPackageReader );
+
+        qualifiedIdentifierRestricionDescr.setText( expression );
+        
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof FieldConstraintDescr ) {
+            final FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) parent;
+            fieldConstraintDescr.addRestriction( qualifiedIdentifierRestricionDescr );
+        } else if ( parent instanceof RestrictionConnectiveDescr ) {
+            final RestrictionConnectiveDescr restrictionConDescr = (RestrictionConnectiveDescr) parent;
+            restrictionConDescr.addRestriction( qualifiedIdentifierRestricionDescr );
+        }
+        return qualifiedIdentifierRestricionDescr;
+    }
+
+    public Class generateNodeFor() {
+        return QualifiedIdentifierRestrictionDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QueryHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/QueryHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QueryHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/QueryHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,95 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class QueryHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public QueryHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PackageDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FunctionDescr.class );
+            this.validPeers.add( RuleDescr.class );
+            this.validPeers.add( QueryDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String queryName = attrs.getValue( "name" );
+        emptyAttributeCheck( localName, "name", queryName, xmlPackageReader );
+
+        final QueryDescr queryDescr = new QueryDescr( queryName.trim() );
+
+        return queryDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final QueryDescr queryDescr = (QueryDescr) xmlPackageReader.getCurrent();
+
+        final AndDescr lhs = queryDescr.getLhs();
+
+        if ( lhs == null || lhs.getDescrs().isEmpty() ) {
+            throw new SAXParseException( "<query> requires a LHS",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        (( PackageDescr ) xmlPackageReader.getData()).addRule( queryDescr );
+
+        return queryDescr;
+    }
+
+    public Class generateNodeFor() {
+        return QueryDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RestrictionConnectiveHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/RestrictionConnectiveHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RestrictionConnectiveHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RestrictionConnectiveHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,107 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.QualifiedIdentifierRestrictionDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class RestrictionConnectiveHandler extends BaseAbstractHandler
+    implements
+    Handler {
+
+    public final static String AND = "and-restriction-connective";
+    public final static String OR  = "or-restriction-connective";
+
+   public RestrictionConnectiveHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( FieldConstraintDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.validPeers.add( LiteralRestrictionDescr.class );
+            this.validPeers.add( ReturnValueRestrictionDescr.class );
+            this.validPeers.add( VariableRestrictionDescr.class );
+            this.validPeers.add( RestrictionConnectiveDescr.class );
+            this.validPeers.add( QualifiedIdentifierRestrictionDescr.class );
+
+            this.allowNesting = true;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        RestrictionConnectiveDescr connectiveDescr = null;
+        if ( localName.equals( RestrictionConnectiveHandler.OR ) ) {
+            connectiveDescr = new RestrictionConnectiveDescr( RestrictionConnectiveDescr.OR );
+        } else if ( localName.equals( RestrictionConnectiveHandler.AND ) ) {
+            connectiveDescr = new RestrictionConnectiveDescr( RestrictionConnectiveDescr.AND );
+        }
+
+        return connectiveDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final RestrictionConnectiveDescr connectiveDescr = (RestrictionConnectiveDescr) xmlPackageReader.getCurrent();
+
+        final Object obj = xmlPackageReader.getParent();
+
+        if ( obj instanceof FieldConstraintDescr ) {
+            final FieldConstraintDescr fieldConstriantDescr = (FieldConstraintDescr) obj;
+            fieldConstriantDescr.addRestriction( connectiveDescr );
+        } else if ( obj instanceof RestrictionConnectiveDescr ) {
+            final RestrictionConnectiveDescr restconective = (RestrictionConnectiveDescr) obj;
+            restconective.addRestriction( connectiveDescr );
+        }
+
+        return connectiveDescr;
+    }
+
+    public Class generateNodeFor() {
+        return RestrictionConnectiveDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ReturnValueRestrictionHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/ReturnValueRestrictionHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ReturnValueRestrictionHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/ReturnValueRestrictionHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,106 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.QualifiedIdentifierRestrictionDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class ReturnValueRestrictionHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public ReturnValueRestrictionHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( FieldConstraintDescr.class );
+            this.validParents.add( RestrictionConnectiveDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+
+            this.validPeers.add( LiteralRestrictionDescr.class );
+            this.validPeers.add( ReturnValueRestrictionDescr.class );
+            this.validPeers.add( VariableRestrictionDescr.class );
+            this.validPeers.add( RestrictionConnectiveDescr.class );
+            this.validPeers.add( QualifiedIdentifierRestrictionDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+        final String evaluator = attrs.getValue( "evaluator" );
+        emptyAttributeCheck( localName, "evaluator", evaluator, xmlPackageReader );
+
+        final ReturnValueRestrictionDescr returnValueDescr = new ReturnValueRestrictionDescr( evaluator );
+
+        return returnValueDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final ReturnValueRestrictionDescr returnValueDescr = (ReturnValueRestrictionDescr) xmlPackageReader.getCurrent();
+
+        final String expression = config.getText();
+        emptyContentCheck( localName, expression, xmlPackageReader );
+
+        returnValueDescr.setContent( expression );
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof FieldConstraintDescr ) {
+            final FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) parent;
+            fieldConstraintDescr.addRestriction( returnValueDescr );
+        } else if ( parent instanceof RestrictionConnectiveDescr ) {
+            final RestrictionConnectiveDescr rcDescr = (RestrictionConnectiveDescr) parent;
+            rcDescr.addRestriction( returnValueDescr );
+        }
+        return returnValueDescr;
+    }
+
+    public Class generateNodeFor() {
+        return ReturnValueRestrictionDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RuleHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/RuleHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RuleHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/RuleHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,115 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+
+import org.drools.lang.descr.AndDescr;
+import org.drools.lang.descr.AttributeDescr;
+import org.drools.lang.descr.FunctionDescr;
+import org.drools.lang.descr.PackageDescr;
+import org.drools.lang.descr.QueryDescr;
+import org.drools.lang.descr.RuleDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * 
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class RuleHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public RuleHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( PackageDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( FunctionDescr.class );
+            this.validPeers.add( RuleDescr.class );
+            this.validPeers.add( QueryDescr.class );
+
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String ruleName = attrs.getValue( "name" );
+        emptyAttributeCheck(localName, "name", ruleName, xmlPackageReader );
+
+        final RuleDescr ruleDescr = new RuleDescr( ruleName.trim() );
+
+        return ruleDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final RuleDescr ruleDescr = (RuleDescr) xmlPackageReader.getCurrent();
+
+        final AndDescr lhs = ruleDescr.getLhs();
+
+        if ( lhs == null ) {
+            throw new SAXParseException( "<rule> requires a LHS",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        final Configuration rhs = config.getChild( "rhs" );
+        if ( rhs == null ) {
+            throw new SAXParseException( "<rule> requires a <rh> child element",
+                                         xmlPackageReader.getLocator() );
+        }
+
+        ruleDescr.setConsequence( rhs.getText() );
+
+        final Configuration[] attributes = config.getChildren( "rule-attribute" );
+        for ( int i = 0, length = attributes.length; i < length; i++ ) {
+            final String name = attributes[i].getAttribute( "name" );
+            emptyAttributeCheck( "rule-attribute", "name", name, xmlPackageReader );
+
+            final String value = attributes[i].getAttribute( "value" );
+
+            ruleDescr.addAttribute( new AttributeDescr( name,
+                                                        value ) );
+        }
+
+        (( PackageDescr ) xmlPackageReader.getData()).addRule( ruleDescr );
+
+        return ruleDescr;
+    }
+
+    public Class generateNodeFor() {
+        return RuleDescr.class;
+    }
+}
\ No newline at end of file

Copied: labs/jbossrules/trunk/drools-compiler/src/main/java/rules/VariableRestrictionsHandler.java (from rev 17100, labs/jbossrules/trunk/drools-compiler/src/main/java/org/drools/xml/VariableRestrictionsHandler.java)
===================================================================
--- labs/jbossrules/trunk/drools-compiler/src/main/java/rules/VariableRestrictionsHandler.java	                        (rev 0)
+++ labs/jbossrules/trunk/drools-compiler/src/main/java/rules/VariableRestrictionsHandler.java	2007-12-10 03:37:32 UTC (rev 17140)
@@ -0,0 +1,102 @@
+package org.drools.xml.rules;
+
+/*
+ * Copyright 2005 JBoss Inc
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ * 
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+import java.util.HashSet;
+import java.util.LinkedList;
+import java.util.ListIterator;
+
+import org.drools.lang.descr.FieldConstraintDescr;
+import org.drools.lang.descr.LiteralRestrictionDescr;
+import org.drools.lang.descr.RestrictionConnectiveDescr;
+import org.drools.lang.descr.ReturnValueRestrictionDescr;
+import org.drools.lang.descr.VariableRestrictionDescr;
+import org.drools.xml.BaseAbstractHandler;
+import org.drools.xml.Configuration;
+import org.drools.xml.ExtensibleXmlParser;
+import org.drools.xml.Handler;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+/**
+ * @author mproctor
+ * TODO To change the template for this generated type comment go to Window -
+ * Preferences - Java - Code Style - Code Templates
+ */
+public class VariableRestrictionsHandler extends BaseAbstractHandler
+    implements
+    Handler {
+    public VariableRestrictionsHandler() {
+        if ( (this.validParents == null) && (this.validPeers == null) ) {
+            this.validParents = new HashSet();
+            this.validParents.add( FieldConstraintDescr.class );
+            this.validParents.add( RestrictionConnectiveDescr.class );
+
+            this.validPeers = new HashSet();
+            this.validPeers.add( null );
+            this.validPeers.add( LiteralRestrictionDescr.class );
+            this.validPeers.add( ReturnValueRestrictionDescr.class );
+            this.validPeers.add( VariableRestrictionDescr.class );
+            this.validPeers.add( RestrictionConnectiveDescr.class );
+            this.allowNesting = false;
+        }
+    }
+
+    public Object start(final String uri,
+                        final String localName,
+                        final Attributes attrs,
+                        final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        xmlPackageReader.startConfiguration( localName,
+                                                  attrs );
+
+        final String evaluator = attrs.getValue( "evaluator" );
+        final String identifier = attrs.getValue( "identifier" );
+        
+        emptyAttributeCheck( localName, "evaluator", evaluator, xmlPackageReader );
+        emptyAttributeCheck( localName, identifier, "identifier", xmlPackageReader );
+
+        final VariableRestrictionDescr variableDescr = new VariableRestrictionDescr( evaluator,
+                                                                                     identifier );
+
+        return variableDescr;
+    }
+
+    public Object end(final String uri,
+                      final String localName,
+                      final ExtensibleXmlParser xmlPackageReader) throws SAXException {
+        final Configuration config = xmlPackageReader.endConfiguration();
+
+        final VariableRestrictionDescr variableDescr = (VariableRestrictionDescr) xmlPackageReader.getCurrent();
+
+        final Object parent = xmlPackageReader.getParent();
+
+        if ( parent instanceof FieldConstraintDescr ) {
+            final FieldConstraintDescr fieldConstraintDescr = (FieldConstraintDescr) parent;
+            fieldConstraintDescr.addRestriction( variableDescr );
+        } else if ( parent instanceof RestrictionConnectiveDescr ) {
+            final RestrictionConnectiveDescr restrictionConDescr = (RestrictionConnectiveDescr) parent;
+            restrictionConDescr.addRestriction( variableDescr );
+        }
+
+        return variableDescr;
+    }
+
+    public Class generateNodeFor() {
+        return VariableRestrictionDescr.class;
+    }
+}
\ No newline at end of file




More information about the jboss-svn-commits mailing list