You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Janek Bogucki <ya...@studylink.com> on 2003/03/11 17:31:55 UTC

[digester] Rule for processing instruction?

I would like to build a map of processing instruction targets and data using
Digester. I can do this by extending Digester

    class PIDigester extends Digester {

        ...constructors...

        public void processingInstruction (
            String target,
            String data
        ) {

            super.processingInstruction ( target, data ) ;
            myMap.put ( target, data ) ;

        }
    }

I'd prefer to collect this information by adding a Rule to a Digester
instance, something similar to this:

    HashMap m = new HashMap () ; // or MultiHashMap
    digester.addRule ( "processing-instruction()", new PIRule ( m ) ) ;

Then this document

    <?xml version="1.0"?>
    <?origin     pg?>
    <?origin-alt fd?>
    <root/>

would result in this map:

    origin:     pg
    origin-alt: fd

Does anyone know if this is already possible or if something similar can be
done without extending Digester?

Many Thanks,
Janek