commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Shishir K. Singh" <sksi...@synapsistech.com>
Subject RE: Betwixt 7 Reading problem
Date Thu, 09 Aug 2007 16:34:13 GMT
Instead of doing 

StringBuffer buffer = new StringBuffer(); 
			String thisLine = "";
			while ((thisLine = reader.readLine()) != null) {

				buffer.append(thisLine);
			}  	
Ty this:

		    	BeanReader beanReader = new BeanReader();
	
beanReader.getBindingConfiguration().setMapIDs(false);
		
	
beanReader.getXMLIntrospector().getConfiguration().setWrapCollectionsInE
lement(false);
	
beanReader.registerBeanClass("ContractDataExtractResponse",ContractDataE
xtractResponseType.class);
			beanReader.registerBeanClass("Status",
StatusType.class);
			beanReader.registerBeanClass("BatchID",
BatchIDType.class);
	
beanReader.registerBeanClass("RecordCount",ContractDataExtractResponseTy
pe_RecordCount.class);

			BufferedReader reader = new BufferedReader(new
InputStreamReader(SirconMockTest.class.getResourceAsStream(batchId
+".xml")));
			conData =
(ContractDataExtractResponseType)beanReader.parse(new
InputSource(reader));

-----Original Message-----
From: lingan [mailto:sathya78.guna@gmail.com] 
Sent: Thursday, August 09, 2007 12:25 PM
To: user@commons.apache.org
Subject: Betwixt 7 Reading problem


Hi I am trying to convert the XML to Java Object . I am getting the
following
excpetion . Any help is highly appreciated.

java.net.MalformedURLException: no protocol:   Successful  56263  4 
	at java.net.URL.(URL.java(Compiled Code))
	at java.net.URL.(URL.java:463)
	at java.net.URL.(URL.java:412)
	at
org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown
Source)
	at
org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown
Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
	at org.apache.xerces.parsers.XML11Configuration.parse(Unknown
Source)
	at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
	at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown
Source)
	at
org.apache.commons.digester.Digester.parse(Digester.java:1605)
	at
com.physiciansmutual.service.sircon.SirconMockTest.extractPacketData(Sir
conMockTest.java:86)
	at
com.physiciansmutual.service.sircon.SirconMockTest.main(SirconMockTest.j
ava:127)
null


Here is my code .

BufferedReader reader = new BufferedReader(new
InputStreamReader(SirconMockTest.class.getResourceAsStream(batchId +
".xml")));
		 	StringBuffer buffer = new StringBuffer(); 
			String thisLine = "";
			while ((thisLine = reader.readLine()) != null) {

				buffer.append(thisLine);
			}  	
			StringReader xmlReader = new
StringReader(buffer.toString());
		    BeanReader beanReader = new BeanReader();
	
beanReader.getBindingConfiguration().setMapIDs(false);
		
beanReader.getXMLIntrospector().getConfiguration().setWrapCollectionsInE
lement(false);
	
beanReader.registerBeanClass("ContractDataExtractResponse",
ContractDataExtractResponseType.class);
			beanReader.registerBeanClass("Status",
StatusType.class);
			beanReader.registerBeanClass("BatchID",
BatchIDType.class);
			beanReader.registerBeanClass("RecordCount",
ContractDataExtractResponseType_RecordCount.class);
			System.out.println("String from XMLReader : " +
buffer.toString());
			//StringEscapeUtils.escapeJava(
			conData =
(ContractDataExtractResponseType)beanReader.parse(buffer.toString());

Thanks.
-- 
View this message in context:
http://www.nabble.com/Betwixt-7-Reading-problem-tf4243596.html#a12075613
Sent from the Commons - User mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message