Hi

I'm currently trying to create a simple example in converting a DRL rule into an XML rule and compiling that but it seems that the XML conversion is not working correctly or have I done something wrong?  Has anyone noticed this problem too?

    public static String convertDrlToXmlRule(String drlRule) throws DroolsParserException
    {
        DrlParser parser = new DrlParser();
        PackageDescr descr = parser.parse(drlRule);

        // Dump to xml rule.
        XmlDumper dumper = new XmlDumper();
        return dumper.dump(descr);
    }

the code above converts a drlRule and dumps out an XML format.

My example drl rule (this compiles fine):

    public static String exampleRule = "package com.rules;" +
                                "import com.rules.my.test.Message;" +
                                "import com.rules.my.test.SubMessage;" +
                                "import com.rules.my.test.SubSubMessage;" +
                                "rule \"exampleRule\"" +
                                "    dialect \"mvel\"" +
                                "    when" +
                                "        Message( $subMessage : subMessage)\n" +
                                "        SubMessage( $subSubMessage : subSubMessage) from $subMessage\n" +
                                "        SubSubMessage( message == \"SubSub\") from $subSubMessage\n" +
                                "    \nthen\n" +
                                "        System.out.println( $subMessage );" +
                                "    end";

What comes out:

<?xml version="1.0" encoding="UTF-8"?>
 <package name="com.rules" 
    xmlns="http://drools.org/drools-4.0"
    xmlns:xs="http://www.w3.org/2001/XMLSchema-instance"
    xs:schemaLocation="http://drools.org/drools-4.0 drools-4.0.xsd">
<import name="com.rules.my.test.Message" />
<import name="com.rules.my.test.SubMessage" />
<import name="com.rules.my.test.SubSubMessage" />
<rule name="exampleRule ">
<rule-attribute name="dialect" value="mvel" />
<lhs>
    <pattern object-type="Message" >
        <field-binding field-name="subMessage" identifier="$subMessage" />
    </pattern>
    <pattern object-type="SubMessage" >
        <field-binding field-name="subSubMessage" identifier="$subSubMessage" />
        <field-binding field-name="subSubMessage" identifier="$subSubMessage" />
        <from>
            <expression> $subMessage </expression>
        </from>
    </pattern>
    <pattern object-type="SubSubMessage" >
        <field-constraint field-name="message">
            <literal-restriction evaluator="==" value="SubSub" />
        </field-constraint>
        <field-constraint field-name="message">
            <literal-restriction evaluator="==" value="SubSub" />
        </field-constraint>
        <from>
            <expression> $subSubMessage </expression>
        </from>
    </pattern>
</lhs>
<rhs>       
    System.out.println( $subMessage );   
</rhs>
</rule>
</package>


If you noticed above it comes out with duplicate field-constaints for pattern SubSubMessage??  However, thats not a big problem, when I try to compile the rule in XML format it throws:

org.xml.sax.SAXParseException: <from> is after an invalid element: org.drools.xml.Handler
    at org.drools.xml.XmlPackageReader.validate(XmlPackageReader.java:506)
    at org.drools.xml.XmlPackageReader.startElement(XmlPackageReader.java:394)
    at org.apache.xerces.parsers.AbstractSAXParser.startElement(Unknown Source)
    at org.apache.xerces.impl.xs.XMLSchemaValidator.startElement(Unknown Source)
    at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanStartElement(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
    at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
    at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
    at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
    at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
    at org.drools.xml.XmlPackageReader.read(XmlPackageReader.java:321)
    at org.drools.xml.XmlPackageReader.read(XmlPackageReader.java:247)


Any suggestions in what I am doing wrong?

Cheers,

Le.