commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject [Betwixt]: Error with a simple .betwixt file
Date Mon, 27 Nov 2006 01:01:17 GMT


Environment: JDK 1.5_02
                         Betwixt: 0.7

Pl help with any suggestions as this seemingly simple problem is
driving me nuts. I have a very simple .betwixt file as shown below:

     <?xml version="1.0" encoding="UTF-8" ?>
     <info primitiveTypes="attribute">
       <element name="Foo">

I attempt to write a an instance of Foo, and register the property mapping as follows:   
		        final String M = "... the XML fragment shown above...";
                        FileWriter outputWriter = ... ;
		        // Betwixt just writes out the bean as a fragment
		        // So if we want well-formed xml, we need to add the prolog
		        outputWriter.write("<?xml version='1.0' ?>\n");
		        // Create a BeanWriter which writes to our prepared stream
		        BeanWriter beanWriter = new BeanWriter(outputWriter);
		        // Configure betwixt
		        beanWriter.getXMLIntrospector().register(new InputSource(new StringReader(M)));

		        // If the base element is not passed in, Betwixt will guess 
		        // But let's write example bean as base element 'license'
		        beanWriter.write("Foo", Foo);

Betwixt throws an exception flagging
an ill formed betwixt file ("Invalid use of <element>. It should be nested inside <info>
or other 
<element> nodes") as shown below:

// Logs:

0    [main] DEBUG org.apache.commons.digester.Digester.sax  - setDocumentLocator(org.apache.xerces.parsers.AbstractSAXParser$LocatorProxy@1c92535)
0    [main] DEBUG org.apache.commons.digester.Digester.sax  - startDocument()
10   [main] DEBUG org.apache.commons.digester.Digester.sax  - startElement(,,info)
10   [main] DEBUG org.apache.commons.digester.Digester  -   Pushing body text ''
10   [main] DEBUG org.apache.commons.digester.Digester  -   New match='info'
10   [main] DEBUG org.apache.commons.digester.Digester  -   No rules found matching 'info'.
10   [main] DEBUG org.apache.commons.digester.Digester.sax  - characters(
10   [main] DEBUG org.apache.commons.digester.Digester.sax  - startElement(,,element)
10   [main] DEBUG org.apache.commons.digester.Digester  -   Pushing body text '
10   [main] DEBUG org.apache.commons.digester.Digester  -   New match='info/element'
10   [main] DEBUG org.apache.commons.digester.Digester  -   Fire begin() for org.apache.commons.betwixt.digester.ElementRule@f1bb78
10   [main] DEBUG org.apache.commons.betwixt.digester.ElementRule  - (BEGIN) name=license
uri=null property=null type=null
10   [main] DEBUG org.apache.commons.betwixt.digester.MappedPropertyRule  - Cannot find property
10   [main] DEBUG org.apache.commons.betwixt.digester.MappedPropertyRule  -   className=null
base=null name=null
40   [main] DEBUG org.apache.commons.betwixt.digester.ElementRule  - 'class' attribute=null
40   [main] WARN  org.apache.commons.digester.Digester  - Empty stack (returning null)
40   [main] ERROR org.apache.commons.digester.Digester  - Begin event threw exception
org.xml.sax.SAXException: Invalid use of <element>. It should be nested inside <info>
or other <element> nodes
	at org.apache.commons.betwixt.digester.ElementRule.begin(
	at org.apache.commons.digester.Digester.startElement(


To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message