commons-user mailing list archives

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

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

<main xmlns:xsi=""

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

My digester XML rules are:

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

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

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

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.


View raw message