I'm trying to use Apache Digester (V3) to process an XML file which contains 'thread-dumps' : so file contains many thread-dumps, one thread-dump contains many threads, and one thread contains a stacktrace, which consists of many lines
Like this: (Simplified)
<threaddumps>
<threaddump name="xxx">
<thread name="thread-1">
<stacktrace>
<line>
java.lang.wait
</line>
<line>
...
</line>
</stacktrace>
</thread>
<thread name="thread-2">
...
</threaddump>
<threaddump name="yyy">
...
</threaddumps>
I am using a XML-based rule to process this input file; fragment below:
<pattern value="thread">
<object-create-rule classname="mypackagemodel.Thread"/>
<set-next-rule methodname="addThread" paramtype="mypackagemodel.Thread"/>
<set-properties-rule>
<alias attr-name="name" prop-name="name" />
</set-properties-rule>
<pattern value="stacktrace/line">
<object-create-rule classname="mypackagemodel.StackLine"/>
<set-next-rule methodname="addStackLine" paramtype="mypackagemodel.StackLine"/>
<!-- need something here -->
</pattern>
</pattern>
How do I pull that text out from the in between 'line' tags though ? I'm already matching on 'stacktrace/line', there is no sub-element to use - so what pattern can I use ?
Another way of putting it - The 'StackLine' object is being created and associated correctly - its just that I don't know what to call my 'setName()' setter with ?
(In XSLT one would generally use '.' or 'current()' in a similar scenario for instance)
Got it : apparently an empty pattern string will match the current node's text:
This worked for me:
<bean-property-setter-rule pattern="" propertyname="line"/>