Hi.

I made a small test to experiment with the org.apache.avalon.configuration package.

I wanted to see what it would do with mixed content, so i fed the following XML file into my Test.java:

XML
===

<root>
        <alpha>apples</alpha>
        <beta>beta content</beta>
        <charlie>cares!</charlie>
        <christie/>
        <doesnt>christie, that is</doesnt>
        <elf><child1/>mixed<child2/></elf>
</root>

OUTPUT
======

alpha : apples
beta : beta content
charlie : cares!
No value is associated with the configuration element "christie"
doesnt : christie, that is
No value is associated with the configuration element "elf"
No value is associated with the configuration element "child1"
child2 : mixed


EXPECTED BEHAVIOUR ==================

I expected it not to like the mixed content inside <elf>. I didn't expect it to say the value of <child2> was "mixed"!

test.java attached.

thanks,

Jason

-------------

package org.apache.avalon.configuration;

class Test {

    public static void main(String[] args) {

ConfigurationBuilder configurationBuilder = new DefaultConfigurationBuilder( "org.apache.xerces.parsers.SAXParser");
Configuration configuration = null;
try {
configuration = configurationBuilder.build( "/tmp/test.xml");
} catch (org.xml.sax.SAXException sae) {
System.out.println( sae.getMessage() );
} catch (java.io.IOException ioe) {
System.out.println( ioe.getMessage() );
} catch (org.apache.avalon.configuration.ConfigurationException ce) {
System.out.println( ce.getMessage() );
}


        Configuration[] children = configuration.getChildren();

        display( children );

    }

public static void display( Configuration[] children) {
for( int i=0; i<children.length; i++) {
try {
System.out.println( children[i].getName() + " : " + children[i].getValue() );
} catch (org.apache.avalon.configuration.ConfigurationException ce) {
System.out.println( ce.getMessage() );
}
if (children[i].getChildren().length!=0 ) {
Configuration[] elfen = children[i].getChildren();
display( elfen);
}
}
}



}


--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to