Yes actually that'd be a good idea, since there's already validation at the end of creating a complex feature (cleanEmptyElements). It also checks for xlink:href there, so it should cover all our problems. The problem is the validation is called inside AttributeImpl() which is a super class of all attributes, outside of app-schema. I think there's a custom attribute/feature factory for app-schema, and an AttributeBuilder class. Perhaps we could then create an alternative non-validating constructor in AttributeImpl and ensure we use this one from these classes, so it'd only affect app-schema related attributes. Dunno if it will work, it's just an idea I have right now.
-----Original Message----- From: andrea.a...@gmail.com [mailto:andrea.a...@gmail.com] On Behalf Of Andrea Aime Sent: Tuesday, 5 October 2010 5:23 PM To: Angreani, Rini (CESRE, Kensington) Cc: Caradoc-Davies, Ben (CESRE, Kensington); geotools-devel@lists.sourceforge.net Subject: Re: [Geotools-devel] Mapping an optional element whose attributes are not optional On Tue, Oct 5, 2010 at 11:13 AM, <rini.angre...@csiro.au> wrote: > OK Victor pointed out that your attributes x and y have minOccurs = 0, and > that they should be skipped. > He actually put in a logic that will skip the parent's attributes if the > children are missing (skipped) and the parent itself is nillable. > However, this is done after the feature is built, after it passes validations > so it's way too late.. And would only work for complex attributes (since they > never get validated). > It's in DataAccessMappingFeatureIterator.cleanEmptyElements(). I guess this > is a bug then.. We need to do something similar for non-complex attributes. Well, I'm ready to try and code a fix if only I get some guidance. A way to handle this could be to move validation to a later stage: first build the feature entirely (and eventually simplify it) and then validate it. Actually if you look at simple features we don't have automatic validation at all, validation is optional and performed only on demand. Wondering if that should just be the default for complex features as well.. it would make some sense, as of now I have a JTS Point inside of a DirectPosition and the store is not complaining. Special casing simple attributes makes for confusing behavior imho (e.g., by default it should validate everything, or nothing at all... and I'd vote for the second). Cheers Andrea ----------------------------------------------------- Ing. Andrea Aime Senior Software Engineer GeoSolutions S.A.S. Via Poggio alle Viti 1187 55054 Massarosa (LU) Italy phone: +39 0584962313 fax: +39 0584962313 http://www.geo-solutions.it http://geo-solutions.blogspot.com/ http://www.linkedin.com/in/andreaaime http://twitter.com/geowolf ----------------------------------------------------- ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb _______________________________________________ Geotools-devel mailing list Geotools-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/geotools-devel