The other problem is that from what you're showing your XML input is not well-formed (more than one root element). This will be a problem if you use the XPP3 parser that's the default with JiBX. If KXML allows this (which I'm assuming from your use of it in your code), you should be able to substitute this for the XPP3 parser since the unmarshalling code uses the XMLPull API that both XPP3 and KXML2 support. I haven't actually tested this, though, and don't know if it will cause problems. Is it possible for you to change the document to be well-formed (by wrapping the whole set of <job>s in some other element)?
- Dennis
Damon Hill wrote:
Good day.
I believe this may be the same as JIRA issue #14, but not 100% sure. Here is the situation. I have the following XML file:
<job> <jobStatus>new</jobStatus> <jobID>111</jobID> <jobType>EDRInspection</jobType> <technicianID>012345</technicianID> <inventoryLocation>CHIRIL</inventoryLocation> <inspectionRepairLocation>IR</inspectionRepairLocation> <accountCode>425</accountCode> <jobCode>105</jobCode> <cause>damage</cause> <jobPosition>09</jobPosition> <damagePosition>11</damagePosition> <damagedArea>roof</damagedArea> <correctionCode/> <condition>cracked</condition> <workPerformed/> </job> <job> <jobStatus>new</jobStatus> <jobID>112</jobID> <jobType>Repair</jobType> <technicianID>012345</technicianID> <inventoryLocation>CHIRIL</inventoryLocation> <inspectionRepairLocation>IR</inspectionRepairLocation> <accountCode>425</accountCode> <jobCode>105</jobCode> <cause>damage</cause> <jobPosition>09</jobPosition> <damagePosition>11</damagePosition> <damagedArea>roof</damagedArea> <correctionCode/> <condition>cracked</condition> <workPerformed/> </job>
I have the following Binding file: <binding> <mapping name="job" class="com.jbhunt.rdcc.application.OutboundJob"> <value name="jobStatus" field="_jobStatus"/> <value name="jobID" field="_jobID"/> <value name="jobType" field="_jobType"/> <value name="technicianID" field="_technicianID"/> <value name="inventoryLocation" field="_inventoryLocation" usage="optional"/> <value name="inspectionRepairLocation" field="_inspectionRepairLocation" usage="optional"/> <value name="accountCode" field="_accountCode" usage="optional"/> <value name="jobCode" field="_jobCode" usage="optional"/> <value name="cause" field="_cause" usage="optional"/> <value name="jobPosition" field="_jobPosition" usage="optional"/> <value name="damagePosition" field="_damagePosition" usage="optional"/> <value name="damagedArea" field="_damagedArea" usage="optional"/> <value name="correctionCode" field="_correctionCode" usage="optional"/> <value name="condition" field="_condition" usage="optional"/> <value name="workPerformed" field="_workPerformed" usage="optional"/> </mapping> </binding>
And I have the following java code to read from the xml and place into a Java object:
public Vector getUserSpecificJobs(String technicianNumber) { Vector userStuff = new Vector(); try { IBindingFactory bfact = BindingDirectory.getFactory(OutboundJob.class); IUnmarshallingContext uctx = bfact.createUnmarshallingContext(); FileInputStream uis = new FileInputStream(RDCCProperties.USER_JOBS_DATA_STORE + technicianNumber + ".xml"); BufferedInputStream bis = new BufferedInputStream(uis); KXmlParser kxp = new KXmlParser(); kxp.setInput(bis, null); kxp.nextTag(); kxp.require(KXmlParser.START_TAG, "", "job"); while(kxp.getEventType() == KXmlParser.START_TAG) { OutboundJob job = (OutboundJob)uctx.unmarshalElement(); System.out.println("Found job \n" + job.toString()); if(job.getTechnicianID().equals(technicianNumber)) { userStuff.add(job); } } } //...exceptions here } return userStuff; }
This doesn't return any values in the Vector userStuff when I call it passing a technicianNumber that matches the file on the local file system. I get two JiBX exceptions of null when I run this.
Any thoughts???
Thanks,
Damon
------------------------------------------------------- This SF.Net email is sponsored by BEA Weblogic Workshop FREE Java Enterprise J2EE developer tools! Get your free copy of BEA WebLogic Workshop 8.1 today. http://ads.osdn.com/?ad_id=4721&alloc_id=10040&op=click _______________________________________________ jibx-users mailing list [EMAIL PROTECTED] https://lists.sourceforge.net/lists/listinfo/jibx-users
