com.github.fge.jsonschema.examples
Class Example5

java.lang.Object
  extended by com.github.fge.jsonschema.examples.Example5

public final class Example5
extends Object

Fifth example: setting a URI namespace; relative URI resolution

link to source code

This example demonstrates another capability of JsonSchemaFactory: the ability to set a URI namespace. This requires to customize the factory, and therefore go through JsonSchemaFactoryBuilder again.

In order to set a URI namespace, we must grab a LoadingConfigurationBuilder, set the namespace, freeze it, and pass it to the factory builder and then freeze the factory.

The net effect is that all schema loading done by SchemaLoader will now resolve against this namespace, and this includes arguments to JsonSchemaFactory.getJsonSchema(String).

The schemas are split in two:

The first refers to the second one via the relative URI mntent.json. This works precisely because a URI namespace has been set: all URIs are resolved against this namespace.

Files validated, and the validation outputs, are the same as for Example2.


Constructor Summary
Example5()
           
 
Method Summary
static void main(String... args)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Example5

public Example5()
Method Detail

main

public static void main(String... args)
                 throws IOException,
                        ProcessingException
Throws:
IOException
ProcessingException