RE: Error compiling schema
Wing Yew Poon <[email protected]> Tue, 28 Sep 2010 15:47:51 -0700 (PDT)
| Newsgroups | gmane.text.xml.xmlbeans.user |
|---|---|
| Message-ID | <4344bb72-7c81-4c5d-8844-9aa0121e7ddb@default> |
I have committed a change to the XMLBeans trunk with the fix for XMLBEANS-396 as suggested by the original reporter, Chris Clark. The earlier change committed by Cezar Andrei as a fix for this issue was evidently incorrect. If you should wish to use the latest XMLBeans, the compilation errors for the EMSDataSet.xsd schema should not occur anymore. Paul Cooper, if you could put together a reproducer for the BigDecimal truncation issue you are seeing (xml schema - the EMSDataSet.xsd would be fine - and test program that only depends on XMLBeans and compiling the schema) and open a JIRA issue for it, that would be very helpful. Thanks, Wing Yew _____ From: Paul Cooper [mailto:[email protected]] Sent: Monday, September 27, 2010 3:50 PM To: [email protected]; [email protected] Subject: RE: Error compiling schema All, Results of my test using code provided by Paul[1] below. Code snippet: Procedure xmlProc = Procedure.Factory.newInstance(); xmlProc.setStringValue(proc.getProcedurePerformed().getCode().toString()); procInfo.xsetE1903(xmlProc); Logging output from my server: Sep 27 2010 12:38 | DEBUG | AbstractXmlBuilder | Created new E19010 Sep 27 2010 12:38 | DEBUG | AbstractXmlBuilder | Added E1901:2010-08-23 10:15:00.0 Sep 27 2010 12:38 | DEBUG | AbstractXmlBuilder | Added E1902:0 Sep 27 2010 12:38 | DEBUG | AbstractXmlBuilder | Added E1903:89.392 Sep 27 2010 12:38 | DEBUG | AbstractXmlBuilder | XML to this point: <E19_01_0 xmlns="http://www.nemsis.org"> <E19_01>2010-08-23T17:15:00.000Z</E19_01> <E19_02>0</E19_02> <E19_03>89.392</E19_03> </E19_01_0> Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1905:1 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1906:1 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1907:4500 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1908:4605 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1909:SC008406 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1910:4625 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1911:-15 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Created new E19010 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1901:2010-08-23 10:16:00.0 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1902:0 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1903:89.51 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | XML to this point: <xml-fragment xmlns:nem="http://www.nemsis.org"> <nem:E19_01_0> <nem:E19_01>2010-08-23T17:15:00.000Z</nem:E19_01> <nem:E19_02>0</nem:E19_02> <nem:E19_03>89.392</nem:E19_03> <nem:E19_05>1</nem:E19_05> <nem:E19_06>1</nem:E19_06> <nem:E19_07>4500</nem:E19_07> <nem:E19_08>4605</nem:E19_08> <nem:E19_09>SC008406</nem:E19_09> <nem:E19_10>4625</nem:E19_10> <nem:E19_11>-15</nem:E19_11> </nem:E19_01_0> <nem:E19_01_0> <nem:E19_01>2010-08-23T17:16:00.000Z</nem:E19_01> <nem:E19_02>0</nem:E19_02> <nem:E19_03>89.51</nem:E19_03> </nem:E19_01_0> </xml-fragment> Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1905:1 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1906:1 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1907:4500 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1908:4605 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1909:SC008406 Sep 27 2010 12:39 | DEBUG | AbstractXmlBuilder | Added E1910:4625 E19 snippet from final XML document: <E19> <E19_01_0> <E19_01>2010-08-23T17:15:00.000Z</E19_01> <E19_02>0</E19_02> <E19_03>89.392</E19_03> <E19_05>1</E19_05> <E19_06>1</E19_06> <E19_07>4500</E19_07> <E19_08>4605</E19_08> <E19_09>SC008406</E19_09> <E19_10>4625</E19_10> <E19_11>-15</E19_11> </E19_01_0> <E19_01_0> <E19_01>2010-08-23T17:16:00.000Z</E19_01> <E19_02>0</E19_02> <E19_03>89.51</E19_03> <E19_05>1</E19_05> <E19_06>1</E19_06> <E19_07>4500</E19_07> <E19_08>4605</E19_08> <E19_09>SC008406</E19_09> <E19_10>4625</E19_10> <E19_11>-15</E19_11> </E19_01_0> </E19> So, using the code provided by Paul[1] and using BigDecimal.toString() gives me the correct output. Now, just for grins, I made a slight change to my original code, getting the code value from my bean and creating a new BigDecimal from that: procInfo.setE1903(new BigDecimal(proc.getProcedurePerformed().getCode().toString())); LOGGER.debug("Added E1903:" + proc.getProcedurePerformed().getCode()); LOGGER.debug("XML to this point:" + e19.toString()); Predictably, the code failed, and it failed immediately, as the E19.toString() generated the incorrect 89 value: Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Created new E19010 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1901:2010-08-23 10:15:00.0 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1902:0 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1903:89.392 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | XML to this point: <E19_01_0 xmlns="http://www.nemsis.org"> <E19_01>2010-08-23T17:15:00.000Z</E19_01> <E19_02>0</E19_02> <E19_03>89.392</E19_03> </E19_01_0> Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1905:1 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1906:1 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1907:4500 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1908:4605 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1909:SC008406 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1910:4625 Sep 27 2010 15:42 | DEBUG | IdleRemover | run: IdleRemover notifying pools, interval: 450000 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1911:-15 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Created new E19010 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1901:2010-08-23 10:16:00.0 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1902:0 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | Added E1903:89.51 Sep 27 2010 15:42 | DEBUG | AbstractXmlBuilder | XML to this point: <xml-fragment xmlns:nem="http://www.nemsis.org"> <nem:E19_01_0> <nem:E19_01>2010-08-23T17:15:00.000Z</nem:E19_01> <nem:E19_02>0</nem:E19_02> <nem:E19_03>89.392</nem:E19_03> <nem:E19_05>1</nem:E19_05> <nem:E19_06>1</nem:E19_06> <nem:E19_07>4500</nem:E19_07> <nem:E19_08>4605</nem:E19_08> <nem:E19_09>SC008406</nem:E19_09> <nem:E19_10>4625</nem:E19_10> <nem:E19_11>-15</nem:E19_11> </nem:E19_01_0> <nem:E19_01_0> <nem:E19_01>2010-08-23T17:16:00.000Z</nem:E19_01> <nem:E19_02>0</nem:E19_02> <nem:E19_03>89</nem:E19_03> </nem:E19_01_0> </xml-fragment> I would suggest that there seems to be a bug in the marshaling code of the BigDecimal. I have done a bit of homework on how many of these we get, and we do get a fair amount of them, and there is no particular value that the problem seems to happen with. Paul[0] From: pgillen [mailto:[email protected]] Sent: Monday, September 27, 2010 10:41 AM To: [email protected] Subject: Re: Error compiling schema The Procedure seemed to be an essential step. -p2- --------- Paul Gillen _____ From: Paul Cooper <[email protected]> Date: Mon, 27 Sep 2010 13:29:34 -0400 To: [email protected]<[email protected]> ReplyTo: [email protected] Subject: RE: Error compiling schema Paul, You're suggesting doing a toString() on the BigDecimal? Hadn't tried that..let me test, I'll report back. Paul From: Gillen, Paul [mailto:[email protected]] Sent: Monday, September 27, 2010 10:23 AM To: '[email protected]' Subject: RE: Error compiling schema This do it? (in terms of solving your problem, not fixing XMLBeans should there be a problem there) I _hate_ BigDecimal. = Paul[1] = _____ throws Exception { EMSDataSetDocument emsDoc = EMSDataSetDocument.Factory.newInstance(); EMSDataSet emsDs = emsDoc.addNewEMSDataSet(); Header hdr = emsDs.addNewHeader(); Record rec1 = hdr.addNewRecord(); E19 rec1_e19 = rec1.addNewE19(); E19010 rec1_e19010a = rec1_e19.addNewE19010(); Procedure p1 = Procedure.Factory.newInstance(); p1.setStringValue("1.1234"); rec1_e19010a.xsetE1903(p1); E19010 rec1_e19010b = rec1_e19.addNewE19010(); Procedure p2 = Procedure.Factory.newInstance(); p2.setStringValue("2.2468"); rec1_e19010b.xsetE1903(p2); System.out.println(emsDoc.toString()); } <EMSDataSet xmlns="http://www.nemsis.org"> <Header> <Record> <E19> <E19_01_0> <E19_03>1.1234</E19_03> </E19_01_0> <E19_01_0> <E19_03>2.2468</E19_03> </E19_01_0> </E19> </Record> </Header> </EMSDataSet> _____ From: Paul Cooper [mailto:[email protected]] Sent: Monday, September 27, 2010 11:24 AM To: [email protected] Subject: RE: Error compiling schema Tim, Your understanding of the problem is correct. This is a repeatable problem. The values being logged are coming directly from the bean's getters, so the value is correct when being added to the XML. And yes, the problem always occurs at the decimal. Interestingly, it seems to happen the SECOND time the E19 element is created. I'll log the XML (it's a pretty big file, hopefully I can log sections) and see what happens. I'll also try to find another PCR with multiple E19 elements. Paul From: Tim Watts [mailto:[email protected]] Sent: Saturday, September 25, 2010 10:14 PM To: [email protected] Subject: RE: Error compiling schema Not exactly sure what's happening here in terms of procedure. My guess is that AbstractXmlBuilder (superclass of XmlPrcBuilder?) is calling setters/"adders" on the target XmlBean and that XmlPcrBuilder is then calling bean.validate(). Is that right? Can you repeat the problem at will or is it still a random thing? Also, when the values are logged are they obtained using the bean's getters or are you logging the original value that the builder receives? If the latter, it might shed some light to log the values obtained from the getters as well. Just for grins & giggles, what if you logged the XML after each set/add. Might shed some light on the point at which 89.51 becomes 89. I'm also curious to know whether the truncation always occurs exactly at the decimal point? On Sat, 2010-09-25 at 23:29 -0400, Paul Cooper wrote: All, I've successfully rebuilt my library with the 2.4 version of XMLBeans, and have successfully replicated the problem with BigDecimals with that version. Here is the logging from my server: Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Created new E19010 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1901:2010-08-23 10:15:00.0 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1902:0 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1903:89.392 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1905:1 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1906:1 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1907:4500 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1908:4605 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1909:SC008406 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1910:4625 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1911:-15 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Created new E19010 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1901:2010-08-23 10:16:00.0 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1902:0 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1903:89.51 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1905:1 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1906:1 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1907:4500 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1908:4605 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1909:SC008406 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1910:4625 Sep 25 2010 20:22 | DEBUG | AbstractXmlBuilder | Added E1911:-15 Sep 25 2010 20:22 | INFO | XmlPcrBuilder | >>>>>>>>>>>>>>>>>>>>>>>> FAILED validation: 5329436 Sep 25 2010 20:22 | INFO | XmlPcrBuilder | Message: W5329436 -- union value '89' does not match any members of 'Procedure in namespace http://www.nemsis.org' Sep 25 2010 20:22 | INFO | XmlPcrBuilder | >>>>>>>>>>>>>>>>>>>>>>>> And here is the XML output. Clearly there is an issue: <E19> <E19_01_0> <E19_01>2010-08-23T17:15:00.000Z</E19_01> <E19_02>0</E19_02> <E19_03>89.392</E19_03> <E19_05>1</E19_05> <E19_06>1</E19_06> <E19_07>4500</E19_07> <E19_08>4605</E19_08> <E19_09>SC008406</E19_09> <E19_10>4625</E19_10> <E19_11>-15</E19_11> </E19_01_0> <E19_01_0> <E19_01>2010-08-23T17:16:00.000Z</E19_01> <E19_02>0</E19_02> <E19_03>89</E19_03> <E19_05>1</E19_05> <E19_06>1</E19_06> <E19_07>4500</E19_07> <E19_08>4605</E19_08> <E19_09>SC008406</E19_09> <E19_10>4625</E19_10> <E19_11>-15</E19_11> </E19_01_0> </E19> Paul