cityjson / specs

Specifications for CityJSON, a JSON-based encoding for 3D city models
https://cityjson.org
Creative Commons Zero v1.0 Universal
107 stars 25 forks source link

Cannot read v8 schema using Altova XMLSpy #34

Closed macumber closed 5 years ago

macumber commented 5 years ago

Altova XMLSpy is a very useful tool for working with JSON files and JSON schemas. When I load in the v8 CityJSON schema, Altova XMLSpy cannot follow the external schema links:

xmlspy_68erxj17eq

I am not sure if this is a limitation of XMLSpy or if the CityJSON schema is not correct. Any of the following solutions would work for me:

  1. Find another graphical schema editor (do you have any suggestions?)
  2. Use a script to combine all the schema's together (does such a script exist?)
  3. Change the CityJSON schema to meet Altova XMLSpy's requirements

Do you have any recommendations?

timoruohomaki commented 5 years ago

Well it doesn't sound right if the schema can only be worked on some specific editor. Have you checked from Altova support if they can say whether that is a non-standard or "alternative convention" that should be supported by the editor? We'd prefer using XMLSpy as well but haven't yet started the project on this one.

kkimmy commented 5 years ago

This is a weird limitation/feature (whatever you wish to call it! :P) of XMLSpy. I had the same error/warning (unable to resolve the reference for "metadata.json" and so on) when I first used the XMLSpy for CityJSON. However, I was able to use XMLSpy to validate CityJSON datasets against the schema without any hassle. IMO, XMLSpy uses the path of "cityjson.json" schema as the base path for all other referenced schemas. So, you can validate a CityJSON dataset using XMLSpy if all your CityJSON schemas are within the same folder. If you delete any referenced schema (e.g. metadata.json) from the schema folder, XMLSpy will give you a "real" validation error.

hugoledoux commented 5 years ago
  1. OxygenXML
  2. not aware of any, I'm planning to write one at some point.
  3. it ain't gonna happen :)
timoruohomaki commented 5 years ago

Got a response from Altova support: "at this time XMLSpy's JSON schema support presently supports draft-04. We do however have an existing feature request in our internal wishes list to support newer versions. " So at the moment, I guess the only option is to switch to OxygenXML

macumber commented 5 years ago

Wow thanks for all the great activity on this ticket!

hugoledoux commented 5 years ago

@macumber stitching them into one is actually super easy:

https://gist.github.com/hugoledoux/4002869e257c56341722f0302a37c73e

macumber commented 5 years ago

Thanks @hugoledoux, not sure if you'd want to provide a single/minified schema with each release or not, Might be useful for people with limited JSON schema parsers.

hugoledoux commented 5 years ago

@macumber good idea, I'll provide the merged one from next version.

but we have an implementation of the validation in cjio that is ready to use, schemas are even included. Details https://github.com/tudelft3d/cjio#validation-of-cityjson-files-against-the-schema

afalk42 commented 5 years ago

We have just released Altova XMLSpy v2019r3 today, which now supports draft-06 and draft-07 of JSON-Schema: https://www.altova.com/xmlspy-xml-editor/whatsnew

Also, please note the following regarding the above issue:

hugoledoux commented 5 years ago

the minified schema for 1.0.0 is available: https://3d.bk.tudelft.nl/schemas/cityjson/1.0.0/cityjson.min.schema.json

it works fine with online apps like that one (https://json-schema-validator.herokuapp.com/) so should work for everything. All $ref have been removed.

afalk42 commented 5 years ago

Hi @hugoledoux The file you are referencing starts with: {"$schema":"http://json-schema.org/draft-04/schema#" so it is specifying draft-04. Therefore, XMLSpy 2019r3 will produce a series of warnings, because this schema file actually uses features of draft-07 already. The fix is very easy - just specify the correct JSON schema version in the file: {"$schema":"http://json-schema.org/draft-07/schema#" Once you do that, XMLSpy will confirm that this file is valid!

hugoledoux commented 5 years ago

What features from v07 is it using?

afalk42 commented 5 years ago

"format": "date" and "format": "uri-reference" For further info, please see also: https://json-schema.org/draft-07/json-schema-release-notes.html#formats

hugoledoux commented 5 years ago

right, indeed.

Just puzzled why my validation tests with dates and URIs were successful then... I use Python jsonschema validator (https://pypi.org/project/jsonschema/), and use v04 explicitly, see https://github.com/tudelft3d/cjio/blob/master/cjio/validation.py#L362

hugoledoux commented 5 years ago

@afalk42 OK, I made some tests and all seems good with v07, and it's there: https://www.dropbox.com/s/t009xhvt1iiscji/cityjson.min.schema.json?dl=0

Can you confirm that it's fine in your software please?

My validator, jsonschema, processed correctly the time and uri even in v04... why I don't know.

afalk42 commented 5 years ago

@hugoledoux I can confirm that the new version you supplied via Dropbox works perfectly fine in XMLSpy v2019r3 now and is considered valid:

Annotation 2019-06-21 102604

hugoledoux commented 5 years ago

cheers, will be in v1.0.1