avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: Configuration - behaviour not as expected?
Date Sun, 15 Apr 2001 00:28:50 GMT
Fixed thanks.

At 03:25  12/4/01 +1000, Jason Harrop wrote:
>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: avalon-dev-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: avalon-dev-help@jakarta.apache.org
>
>
Cheers,

Pete

*-----------------------------------------------------*
| "Faced with the choice between changing one's mind, |
| and proving that there is no need to do so - almost |
| everyone gets busy on the proof."                   |
|              - John Kenneth Galbraith               |
*-----------------------------------------------------*


---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message