Results 1 to 4 of 4
Thread: Empty element parsing issue
- 08-20-2012, 02:04 AM #1
Member
- Join Date
- Jul 2011
- Posts
- 32
- Rep Power
- 0
Empty element parsing issue
Hello,
I am trying to parse an xml document and I am getting parser errors. One of the elements is empty - and this is where I get the errors.
Here is sample code
ERROR
Java Code:java.lang.NumberFormatException: empty String at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1038) at java.lang.Double.valueOf(Double.java:487)
GETTER/SETTER
SAMPLE SCHEMA WHERE IT ERRORSJava Code:@Column(length=10) private Double num=0.0; public Double getNum() { return this.num; } public void setNum(Double num) { //this.num = num == null ? 0.0 : num; this.num = num == null ? Double.NaN : num; } }
SETTING THE VALUE IN THE CLASS - SAXPARSERJava Code:<object> <label>label</label> <num/> // it errors here <units>zero</units> </object>
Can anyone offer any advice ?Java Code:if(qName.equalsIgnoreCase("num")){ Tmp.setNum(Double.valueOf(String).doubleValue());
Thanks in advance
- 08-20-2012, 03:53 AM #2
Re: Empty element parsing issue
You left of the part of the error message that shows where in your code the error happened.
Can you make a small, complete program that compiles, executes and shows the problem?If you don't understand my response, don't ignore it, ask a question.
- 08-20-2012, 04:25 AM #3
Member
- Join Date
- Jul 2011
- Posts
- 32
- Rep Power
- 0
Re: Empty element parsing issue
Here is the error
Here is the xml file with the detailJava Code:label is B6 G151 Rel Lab 1 in end label in the start element in the end element begining the transaction get entity manger going to begin going to perist going to commit java.lang.NullPointerException at sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:1035) at java.lang.Double.valueOf(Double.java:487) at com.ibm.north.northCommander.endElement(northCommander.java:154) at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanEndElement(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source) at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)in the end element begining the transaction get entity manger going to begin going to perist going to commit 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.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source) at com.ibm.north.northCommander.main(northCommander.java:313) in end object
I am using JPA to persist the data into the database with an entity managerJava Code:<object id="P32O3" type="num" status="ok" updated="2012-08-20T02:52:18"> <label>B6 G32 SDF Rel Lab</label> <num>101.17</num> <units>KW</units> </object> <object id="P32O4" type="num" status="ok" updated="2012-05-28T15:55:36" logavailable="true"> <label>B6 G151 Rel Lab 1 </label> <num/> object> <object id="P32O5" type="num" status="ok" updated="2012-08-20T02:52:19" logavailable="true"> <label>B6 G39 Server A</label> <num>14590.47</num> <units>KW</units> </object>
Java Code:public String createRawData(RawData RawData) throws Exception { System.out.println("begining the transaction"); EntityManager em = getEntityManager(); System.out.println("get entity manger"); try { System.out.println("going to begin"); em.getTransaction().begin(); System.out.println("going to perist"); em.persist(northRawData); System.out.println("going to commit"); em.getTransaction().commit(); } catch (Exception ex) { try { if (em.getTransaction().isActive()) { em.getTransaction().rollback(); } } catch (Exception e) { ex.printStackTrace(); throw e; } throw ex; } finally { em.close(); } return ""; }
- 08-20-2012, 04:31 AM #4
Similar Threads
-
[SOLVED] Empty JTable issue(blank rows)
By doru.chiulan in forum AWT / SwingReplies: 3Last Post: 08-10-2012, 08:06 AM -
error for empty element in sax parser
By alexandra12 in forum XMLReplies: 9Last Post: 08-01-2012, 12:59 AM -
SAX Parsing element containing html
By ianstanton in forum XMLReplies: 1Last Post: 04-20-2011, 08:21 AM -
Digester parsing and Lucene indexing: empty index...
By aneuryzma in forum LuceneReplies: 0Last Post: 02-24-2011, 03:37 PM -
XML Parsing, strange empty/duplicated Nodes
By Singing Boyo in forum Advanced JavaReplies: 0Last Post: 08-18-2009, 06:57 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks