commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Dubchak, John D" <John.Dubc...@anheuser-busch.com>
Subject Newbie Digester XML rules issues
Date Mon, 19 Dec 2005 18:00:58 GMT
Hi,

I'm having difficulty writing my XML-based digester rules to parse a simple XML
file:

<main xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
               xsi:noNamespaceSchemaLocation="myschema.xsd">

    <scenario classname="ScenarioClass">
        <child classname="ScenarioChildClass">
            <handler classname="SomeotherClass"/>
        </child>
        <child classname="AnotherScenarioChildClass"/>
        <child classname="YetAnotherScenarioChildClass"/>
    </scenario>
    
</main>

My digester XML rules are:

<object-create-rule pattern="parent" classname="java.util.ArrayList" />
<pattern value="main/scenario">
    <object-create-rule classname="Scenario"/>
    <set-properties-rule/>
    <pattern value="main/scenario/child">
        <object-create-rule classname="ChildMetaData"/>
        <set-properties-rule/>
            <pattern value="main/scenario/child/handler">
                <call-method-rule methodname="setHandler" paramcount="1"/>  
                <call-param-rule paramnumber='0' attrname='classname'/>
            </pattern>

        <set-next-rule methodname="setChildMetaData"/>
    </pattern>
    <set-next-rule methodname="add" />
</pattern>

Essentially, what I'm striving for is when the main/scenario tag is encountered,
create an instance of a Scenario class.  This occurs as it should.  

However, when it encounters main/scenario/child I would like it to create an
object of type ChildMetaData and associate the attribute of
main/scenario/child/handler specified by classname by calling the setHandler
method of ChildMetaData, then adding ChildMetaData to Scenario by calling
setChildMetaData.  Then the Scenario object gets added as an element of an
ArrayList.

I'm new to digester and have looked through the archives and the samples in the
source distro but am puzzled as to what I might be missing.

Any help is appreciated.

Thanks,
John

Mime
View raw message