From: Frank C. <fc...@pu...> - 2004-10-05 18:12:02
|
I'm using a JAXB created XML binding to output logged results to a file. The binding lets me marshal an XML tree using this form: # Import the JAXB classes from javax.xml.bind import JAXBContext; from javax.xml.bind import JAXBException; from javax.xml.bind import Marshaller; # Import Java content classes generated by JAXB binding compiler from com.pushtotest.tool.xml.results import ObjectFactory from com.pushtotest.tool.xml.results import Testmaker # Import TestMaker methods from com.pushtotest.testmaker.gui import TestMaker from code import InteractiveInterpreter # Create the JAXBContext and object factory rc = JAXBContext.newInstance( "com.pushtotest.tool.xml.results" ) objFactory = ObjectFactory() # Create an empty TestMaker element entry tm = objFactory.createTestmaker() tm.setVersion( 1 ) resp = objFactory.createResponse() tm.setResponse( resp ) resp.setUrl("http://examples.pushtotest.com") # create a Marshaller and marsall to console m = rc.createMarshaller() m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, 1 ) m.marshal( tm, testmaker.getOutputStream() ) Unfortunately the m.setProperty() method throws an exception that complains that the second parameter needs to be a boolean value. It appears Jython is passing-in an integer one value instead of a boolean true. I even tried the following: from java.lang import Boolean b = Boolean("true").booleanValue() m.setProperty( Marshaller.JAXB_FORMATTED_OUTPUT, b ) But that gives the same results, the setProperty method gets an int instead of a boolean. Any ideas? -Frank --- Frank Cohen, PushToTest, http://www.PushToTest.com, phone: 408 374 7426 Author of "Java Testing and Design: From Unit Tests to Automated Web Tests" from Prentice Hall, details at http://thebook.pushtotest.com |