@@ -90,11 +90,47 @@ static Schema getSchema(Schema parentSchema, SchemaContext schemaContext, String
9090 }
9191 return refSchema ;
9292 }
93+
94+ static Schema getSchema (Schema parentSchema , ExecutionContext executionContext ) {
95+ Schema refSchema = parentSchema .findSchemaResourceRoot (); // Get the document
96+ Schema current = refSchema ;
97+ Schema check = null ;
98+ String base = null ;
99+ String baseCheck = null ;
100+ if (refSchema != null )
101+ base = current .getSchemaLocation ().getAbsoluteIri () != null ? current .getSchemaLocation ().getAbsoluteIri ().toString () : "" ;
102+ if (current .isRecursiveAnchor ()) {
103+ // Check dynamic scope
104+ for (Iterator <Schema > iter = executionContext .getEvaluationSchema ().descendingIterator (); iter .hasNext ();) {
105+ current = iter .next ();
106+ baseCheck = current .getSchemaLocation ().getAbsoluteIri () != null ? current .getSchemaLocation ().getAbsoluteIri ().toString () : "" ;
107+ if (!base .equals (baseCheck )) {
108+ base = baseCheck ;
109+ // Check if it has a dynamic anchor
110+ check = current .findSchemaResourceRoot ();
111+ if (check .isRecursiveAnchor ()) {
112+ refSchema = check ;
113+ }
114+ }
115+ }
116+ }
117+ if (refSchema != null ) {
118+ System .out .println (refSchema );
119+ // refSchema = refSchema.fromRef(parentSchema, evaluationPath);
120+ }
121+ return refSchema ;
122+ }
93123
94124 @ Override
95125 public void validate (ExecutionContext executionContext , JsonNode node , JsonNode rootNode , NodePath instanceLocation ) {
96-
97126 Schema refSchema = this .schema .getSchema ();
127+ /*
128+ Schema check = getSchema(this.parentSchema, executionContext);
129+ if (refSchema != null && !refSchema.getSchemaLocation().equals(check.getSchemaLocation())) {
130+ System.out.println(check);
131+ System.out.println(refSchema);
132+ }
133+ */
98134 if (refSchema == null ) {
99135 Error error = error ().keyword (KeywordType .RECURSIVE_REF .getValue ())
100136 .messageKey ("internal.unresolvedRef" ).message ("Reference {0} cannot be resolved" )
0 commit comments