jsonx-org / schema

"JSON Schema Definition" (JSD) language that offers a vocabulary to describe the structure and constraining the contents of JSON documents.
https://jsonx.org/schema/
MIT License
4 stars 1 forks source link

Assert no duplicate field name in common property binding context #11

Open safris opened 11 months ago

safris commented 11 months ago

In the following example, each of the 4 paths bind to field "a". Since the context of each binding is object "o", the fields collide.

<binding>
  <xi:include href="schema.jsdx"/>

  <any path="o[0]"><bind lang="java" field="a"/></any>
  <reference path="o.r"><bind lang="java" field="a"/></reference>
  <boolean path="o.b"><bind lang="java" field="a"/></boolean>
  <number path="o.n"><bind lang="java" field="a"/></number>
  <string path="o.s"><bind lang="java" field="a"/></string>

</binding>

This can be detected by something akin <xs:assert test="count(replace($path, '([^\\]|\\\\)[\.\[].*', concat('$1.', $field)) = count(distinct-values(replace($path, '([^\\]|\\\\)[\.\[].*', concat('$1.', $field)))"/>.