Hi, I created an issue (ttps://osgeo-org.atlassian.net/browse/GEOT-5503).
I can provide a pull request for this issue. Proposed solution: The layer above (GMLComplexTypes.AbstractFeatureType) is skipping the printing of null attributes. I had a look at the code and it seemed to me as the implementations of encode() often deny printing null values throwing an exception. In case of XSISimpleType implementations however, the behaviour would change: Currently empty elements will be printed. With the proposed solution the elements for null values will be omitted. This is of course quite a big change. Maybe its better to introduce a special case, so that simple attributes are still written to maintain backwards compatibility? They might be required by some XSD validators on the server-side for example. On the other hand the empty elements are just superfluous. Can please anybody decide which way to go? I would opt for backwards compatibility. Best regards, Andreas 2016-08-30 17:51 GMT+02:00 Andrea Aime <[email protected]>: > On Tue, Aug 30, 2016 at 5:38 PM, Andreas Watermeyer < > [email protected]> wrote: > >> >> From org.geotools.xml.gml.GMLComplexTypes$MultiPolygonPropertyType: >> >> public void encode(Element element, Object value, PrintHandler output, >> Map hints) throws IOException, OperationNotSupportedException >> { >> if ((value == null) || !(value instanceof MultiPolygon)) { >> throw new OperationNotSupportedException("Value is >> "+value == null?"null":value.getClass().getName()); >> } >> ... >> } >> >> (Instead of the desired OperationNotSupportedException a NPE is thrown >> because of operator precedence.) >> >> Question: >> - Why the exception? >> > > Simple bug > > >> It would have been quite easy to just skip null >> values and write nothing instead. >> > > The implementer evidently did not think about this case. We are humans and > make mistakes. > I'm for one surprised the encoding reaches down to the binding to start > with, I would expected the > upper layers to just skip encoding the property, or encode an empty > element with a "null reason" attribute. > The issue might actually be there, in the feature encode method, as > opposed to the geometry binding one. > > >> - What is the suggested solution? I have tried to encode an empty >> Multipolygon instead but it fails, too. >> > > I'd start by opening a ticket. A pull request with a fix and a test would > make the perfect pair with it :-p > > >> PS: Somebody on FOSS4G noted, that there is a lack of positive >> feedback from the community regarding GeoServer and GeoTools. >> For my part: I think both project are great and the amount a features >> is overwhelming. Many thanks to the developers and the community! Both >> thumbs up! >> > > Thanks > > Cheers > Andrea > > -- > == > GeoServer Professional Services from the experts! Visit > http://goo.gl/it488V for more information. > == > > Ing. Andrea Aime > @geowolf > Technical Lead > > GeoSolutions S.A.S. > Via di Montramito 3/A > 55054 Massarosa (LU) > phone: +39 0584 962313 > fax: +39 0584 1660272 > mob: +39 339 8844549 > > http://www.geo-solutions.it > http://twitter.com/geosolutions_it > > *AVVERTENZE AI SENSI DEL D.Lgs. 196/2003* > > Le informazioni contenute in questo messaggio di posta elettronica e/o > nel/i file/s allegato/i sono da considerarsi strettamente riservate. Il > loro utilizzo è consentito esclusivamente al destinatario del messaggio, > per le finalità indicate nel messaggio stesso. Qualora riceviate questo > messaggio senza esserne il destinatario, Vi preghiamo cortesemente di > darcene notizia via e-mail e di procedere alla distruzione del messaggio > stesso, cancellandolo dal Vostro sistema. Conservare il messaggio stesso, > divulgarlo anche in parte, distribuirlo ad altri soggetti, copiarlo, od > utilizzarlo per finalità diverse, costituisce comportamento contrario ai > principi dettati dal D.Lgs. 196/2003. > > > > The information in this message and/or attachments, is intended solely for > the attention and use of the named addressee(s) and may be confidential or > proprietary in nature or covered by the provisions of privacy act > (Legislative Decree June, 30 2003, no.196 - Italy's New Data Protection > Code).Any use not in accord with its purpose, any disclosure, reproduction, > copying, distribution, or either dissemination, either whole or partial, is > strictly forbidden except previous formal approval of the named > addressee(s). If you are not the intended recipient, please contact > immediately the sender by telephone, fax or e-mail and delete the > information in this message that has been received in error. The sender > does not give any warranty or accept liability as the content, accuracy or > completeness of sent messages and accepts no responsibility for changes > made after they were sent or for other risks which arise as a result of > e-mail transmission, viruses, etc. > > ------------------------------------------------------- >
------------------------------------------------------------------------------
_______________________________________________ GeoTools-GT2-Users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/geotools-gt2-users
