Yes, I have been struggling with exactly the same exception thrown
Types.validate.
What I am trying to apply now is band-aids from app-schema, but it would
be a good idea if our issues can lead to a better solution alltogether.
Remark that if we would check for xlink:href in Types.validate that
would mean that
- the validate method needs to know whether xlink:href is present or not
(currently it doesn't have that information)
- that would mean that the userdata with clientproperties needs be
passed on in the constructor of AttributeImpl (currently not possible)
- that means the constructor of AttributeImpl should be taking the
clientproperties out of the user data and then taking the Xlink:Href xml
attribute out of the clientproperties. Hmmm, if the AttributeImpl is
aware of this structure, does it still make sense to be using the
userdata map for this purpose? Just a thought.
Niels
On 05/10/10 16:45, [email protected] wrote:
You can only use functions to skip the attribute if you use the feature
chaining syntax.
I said "syntax", because you can omit linkField, therefore it's not really chaining it
and won't generate the extra "joining" queries, it only recycles the syntax.
http://docs.geoserver.org/latest/en/user/data/app-schema/polymorphism.html#data-type-polymorphism
"You can omit the linkField and OCQL if the FeatureTypeMapping being linked to has
the same sourceType with the container type. This would save us from unnecessary extra
queries, which would affect performance."
Anyway, you can't use the functions because you can't "chain" simple attributes
(seeing both x and y are xs:integer).
However, I know what the problem is.
If you refer to this: http://jira.codehaus.org/browse/GEOT-2679, it was decided
that if the value is null and:
1. IF minOccur == 0 THEN skip the attribute silently
2. IF minOccur> 0&& nillable THEN let it pass through validation in
Types.validate()
3. IF minOccur> 0&& !nillable THEN it will throw an error through validation
in Types.validate()
So, it's correct that it throws the error, as the attribute shouldn't be null.
Normally, we put an xlink:href in the ClientProperty when the values are
missing, i.e. one of these:
urn:ogc:def:nil:OGC::inapplicable
urn:ogc:def:nil:OGC::missing
urn:ogc:def:nil:OGC::template
urn:ogc:def:nil:OGC::unknown
urn:ogc:def:nil:OGC::withheld
Maybe that's what you need, and the use case that's missing is:
4. IF minOccur> 0&& !nillable&& has xlink HREF THEN it should pass through
validation Types.validate()
We never had this problem for complex attributes, because they never have null
as a value, but an empty array instead(since the binding is a Collection for
complex types).
Actually, Niels is working on the same problem, but it's for Geometry
attributes, and you're working on simple attributes.
What I think we should do is add another condition in the validate method to
check for xlink:href (from the attribute descriptor user data):
if (attributeContent == null) {
--> check for xlink:href here and skip the following
if (!attribute.isNillable()) {
throw new IllegalAttributeException(attribute.getDescriptor(),
type.getName()
+ " not nillable");
}
return;
}
I will get Niels to speak to you as well.
I like that you're working on app-schema and fix all our existing problems :)
Cheers
Rini
-----Original Message-----
From: Caradoc-Davies, Ben (CESRE, Kensington)
Sent: Tuesday, 5 October 2010 4:14 PM
To: Andrea Aime
Cc: Geotools-Devel list; Angreani, Rini (CESRE, Kensington)
Subject: Re: [Geotools-devel] Mapping an optional element whose attributes are
not optional
I think you want these:
http://docs.geoserver.org/latest/en/user/data/app-schema/polymorphism.html#null-or-missing-value
http://docs.geoserver.org/latest/en/user/data/app-schema/polymorphism.html#recode-function
But I don't know if they will help without feature chaining. Rini?
On 05/10/10 16:04, Andrea Aime wrote:
Hi,
in my target schema I have this attribute:
<xs:element name="positionAccuracyVector"
type="csn:PositionAccuracyVectorType" minOccurs="0"/>
<xs:complexType name="PositionAccuracyVectorType">
<xs:sequence>
<xs:element name="x" type="xs:integer">
</xs:element>
<xs:element name="y" type="xs:integer">
</xs:element>
</xs:sequence>
</xs:complexType>
As you can see the attribute is optional, but the x/y inside of it are not.
I made the following mappings (no feature chaining):
<AttributeMapping>
<targetAttribute>
csndc:positionAccuracyVector/x
</targetAttribute>
<sourceExpression>
<OCQL>position_accuracy_x</OCQL>
</sourceExpression>
</AttributeMapping>
<AttributeMapping>
<targetAttribute>
csndc:positionAccuracyVector/y
</targetAttribute>
<sourceExpression>
<OCQL>position_accuracy_y</OCQL>
</sourceExpression>
</AttributeMapping>
But the database contains also nulls for the two attributes. I hoped the
app-schema store was smart enough to see all the attributes were null
and decide not to create the positionAccuracy attribute, but unfortunately
that did not work and I get the following exception:
org.geotools.feature.IllegalAttributeException:http://www.w3.org/2001/XMLSchema:integer
not nillable:null value:null
at org.geotools.feature.type.Types.validate(Types.java:112)
at org.geotools.feature.type.Types.validate(Types.java:80)
at org.geotools.feature.AttributeImpl.<init>(AttributeImpl.java:51)
at
org.geotools.feature.AppSchemaFeatureFactoryImpl.createAttribute(AppSchemaFeatureFactoryImpl.java:63)
at
org.geotools.feature.AttributeBuilder.create(AttributeBuilder.java:583)
at org.geotools.feature.AttributeBuilder.add(AttributeBuilder.java:495)
at org.geotools.data.complex.filter.XPath.setValue(XPath.java:769)
Looking at the docs and the AppSchemaDataAccess.xsd grammar I see no
way to tell
the app schema store whether a attribute is actually present or not.
Am I missing some feature, is this a bug or... what? :-)
Maybe feature chaining can be used to solve this riddle, but I'm
trying to avoid it like a plague,
I cannot have n queries made for each feature returned.
I guess this might be yet another candidate for xslt-ing...
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel
--
Ben Caradoc-Davies<[email protected]>
Software Engineering Team Leader
CSIRO Earth Science and Resource Engineering
Australian Resources Research Centre
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel
--
*Niels Charlier*
Software Engineer
CSIRO Earth Science and Resource Engineering
Phone: +61 8 6436 8914
Australian Resources Research Centre
26 Dick Perry Avenue, Kensington WA 6151
------------------------------------------------------------------------------
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
[email protected]
https://lists.sourceforge.net/lists/listinfo/geotools-devel