Dear Christian,

it's very great that you've incorporated the SAXSerializer. But you've overdone it a bit. The setItem() method and the parse() methods are required. I've written a JUnit-Test to demonstrate the application of the SAXSerializer with JAXB.

In line 49 there should be the method setItem, which you have removed. The JAXB unmarshaller is going to invoke parse(String) which now throws an exception with an 'unimplemented' note.

So please re-enable the parse()-methods and re-introduce the setItem()-method.

package basex.test.sax;

import java.io.File;

import javax.xml.bind.JAXBContext;
import javax.xml.transform.Source;
import javax.xml.transform.sax.SAXSource;

import junit.framework.Assert;

import org.basex.core.Context;
import org.basex.core.cmd.CreateDB;
import org.basex.io.serial.SAXSerializer;
import org.basex.io.serial.Serializer;
import org.basex.query.QueryProcessor;
import org.basex.query.value.item.Item;
import org.junit.Test;

public class SAXSerializerTest
{
        @Test
        public void unmarshallJAXBObjectWithSAXSerializer() throws Exception
        {
                File temp = getTemp();
                JAXBContext jaxbContext = JAXBContext.newInstance(DomainObject.class);

                // create XML
                File input = new File(temp, "input.xml");
                jaxbContext.createMarshaller().marshal(new DomainObject("Object1", 42), input);

                // create DB
                System.setProperty("org.basex.path", temp.getAbsolutePath());
                Context context = new Context();
                new CreateDB("test1", input.getAbsolutePath()).execute(context);

                // get object from DB
                QueryProcessor queryProcessor = new QueryProcessor("//domain-object[@name='Object1']", context);
                Item item1 = queryProcessor.iter().next();

                // write out to see that item is here
                Serializer serializer1 = queryProcessor.getSerializer(System.out);
                serializer1.serialize(item1);
                serializer1.close();

                SAXSerializer saxSerializer = new SAXSerializer();
                SAXSource saxSource = new SAXSource(saxSerializer, null);

                // this is needed!!!
                saxSerializer.setItem(item1);
                DomainObject domainObject1 = jaxbContext.createUnmarshaller().unmarshal(saxSource, DomainObject.class).getValue();

                queryProcessor.close();

                Assert.assertEquals(42, domainObject1.getValue());
        }

        private File getTemp()
        {
                File temp = new File("d:/temp/basex"); //System.getProperty("java.io.tmpdir");
                temp.mkdirs();
                return temp;
        }
}

The code is attached to this mail.