commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gary and sarah <>
Subject [digester] digester adds sub-objects before fully created
Date Sun, 09 May 2004 13:05:29 GMT
    I seem to have a problem

I am using digester to read the following file

<?xml version="1.0"?>
<tensor_frame xmlns="">
    <x_axis> <x>1.0</x><y>0.0</y><z>0.0</z>  </x_axis>
    <y_axis> <x>0.0</x><y>1.0</y><z>0.0</z>  </y_axis>
    <y_axis> <x>0.0</x><y>0.0</y><z>1.0</z>  </y_axis>

with the following as an example of a rules

        // x axis


        digester.addBeanPropertySetter ("tensor_frame/x_axis/x", "x");
        digester.addBeanPropertySetter ("tensor_frame/x_axis/y", "y");
        digester.addBeanPropertySetter ("tensor_frame/x_axis/z", "z");
        digester.addSetNext("tensor_frame/x_axis", "addProjections");

        // tensor_frame
        digester.addObjectCreate("tensor_frame", BasicTensorFrame.class);

however, basicTensorFrame.addprojections is being called with an 
impcompletely constructed BasicProjections object...

this apppears to be because the end clauses of rules are being called in 
the reverse order from that in which they are declared:

vis in the source code for digester.endElement:

| // Fire "end" events for all relevant rules in reverse order
        if (rules != null) {
            for (int i = 0; i < rules.size(); i++) {
                int j = (rules.size() - i) - 1;
                try {
                    Rule rule = (Rule) rules.get(j);
                    if (debug) {
                        log.debug("  Fire end() for " + rule);
                    rule.end(namespaceURI, name);
                } catch (Exception e) {
                    log.error("End event threw exception", e);
                    throw createSAXException(e);
                } catch (Error e) {
                    log.error("End event threw error", e);
                    throw e;

Is this a clever design decision [I happily admit that I am a new user 
to this package and am happy to stand corrected ] or is it as it seems 
to me a bit perverse...

  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message