Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion Understanding how the IDs are handled when the schema has no provenance.

Received: by 10.52.72.230 with SMTP id g6mr6164258vdv.5.1331334785321;
        Fri, 09 Mar 2012 15:13:05 -0800 (PST)
X-BeenThere: json-schema@googlegroups.com
Received: by 10.221.11.200 with SMTP id pf8ls5501715vcb.0.gmail; Fri, 09 Mar
 2012 15:13:04 -0800 (PST)
Received: by 10.52.24.244 with SMTP id x20mr688640vdf.11.1331334784476;
        Fri, 09 Mar 2012 15:13:04 -0800 (PST)
Date: Fri, 9 Mar 2012 15:13:03 -0800 (PST)
From: Xample <flavien.vol...@gmail.com>
To: json-schema@googlegroups.com
Message-ID: <27779470.1025.1331334784027.JavaMail.geo-discussion-forums@vbtf26>
In-Reply-To: <CALcybBCwGTXicSjYfzUNeeiQMVjw69cnt-oyFAW9vsMriRnuOg@mail.gmail.com>
References: <32890996.4684.1331118544975.JavaMail.geo-discussion-forums@ynlt17>
 <CALcybBDBmVGY93wDrrKi_Z6PingPy0t6i7PK5HS3CMpCXmWpCw@mail.gmail.com>
 <6532499.5197.1331139245472.JavaMail.geo-discussion-forums@ynlt17>
 <CALcybBD26Un6bbD+3+q2xttyouVOypgjowBkLCSMnbyo0mXQ7A@mail.gmail.com>
 <29936184.10.1331193727447.JavaMail.geo-discussion-forums@vbbp15>
 <CALcybBDD3JNC8UH9iARJ_JWxq2bNvsdw3NgEH0hTe1DScKbPWg@mail.gmail.com>
 <7207681.21.1331281692236.JavaMail.geo-discussion-forums@vbne13>
 <CALcybBCwGTXicSjYfzUNeeiQMVjw69cnt-oyFAW9vsMriRnuOg@mail.gmail.com>
Subject: Re: [json-schema] Understanding how the IDs are handled when the
 schema has no provenance.
MIME-Version: 1.0
Content-Type: multipart/mixed; 
	boundary="----=_Part_1023_7946879.1331334784026"

------=_Part_1023_7946879.1331334784026
Content-Type: multipart/alternative; 
	boundary="----=_Part_1024_16560256.1331334784026"

------=_Part_1024_16560256.1331334784026
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: quoted-printable



- As the validators uniformity matters, I would suggest to make an open=20
json-schema test unit in order everyone to conform his validator to the=20
same behavious (especially in tricky cases).

- Reading an RFC is never a pleasure, examples covering all the cases (if=
=20
applicable) would strongly help (if we can join this with a common test=20
unit=E2=80=A6)

- I opened a topic concerning the trailing slash / in json pointers (very=
=20
nice to have notices this)

- Overriding the path #/properties/anOverridenPath with the scheme=20
{"deny":"any"}, would make the following document invalid=20
{"anOveridenPath":"something"}; (this could have been useful in MongoDB=20
queries)


For your proposal:

1. I do not agree again. The rfc specifies the following fallback : id=20
relatively to the url where the shema has been got, relatively to the=20
environment. This is only a matter of building absolute paths from relative=
=20
one.The rfc RFC 2396 tells how to do it, you should be able to use the=20
java.net.URL by URL url =3D new URL( "http://base.com/url" ,=20
"../relativeOne.html");

Normally: new URL( "http://absoluteOne.com" , "http://notARelative.com"); w=
ill=20
give you http://notARelative.com


Try:=20

String environment =3D "urn:"; // your fallback scheme (you could have made=
 a=20
whole fallback id as well "urn:uuid:123456")

String downloadedFrom =3D "//www.domain.com/theFile.json";

downloadedFrom =3D (new URL( environment , downloadedFrom)).toString(); //=
=20
will absolutize the downloadedFrom url

String rootID =3D "#fragmentName";

rootID =3D (new URL( downloadedFrom , rootID)).toString(); // will absoluti=
ze=20
the rootID


-> rootID should be =3D urn://www.domain.com/theFile.json/#fragmentName

-> index your schema in a dictionary under the (absolute and normalized)=20
url rootID, you are done=E2=80=A6

-> add one more step for inner schema (where the absolute path will be the=
=20
rootID and the relative one the id's url)


If your rootID has been "http://www.mickey.com/#" it would simply not have=
=20
been changed.

If the downloadedFrom has been =3D "", we would simply omitted this step. (=
new=20
URL( anAbsolutePath , "")).toString().equals(anAbsolutePath) is true.



2. Any url but no fragment path (json pointers) -> no more overriding,=20
well=E2=80=A6 not bad in some way

3. An id should be unique -> I agree, this said it should be already the=20
case (or would you validate them all ? :-) )

4. a. about url normalization=20
http://en.wikipedia.org/wiki/URL_normalization , probably that using the=20
URL class will get rid of this problem itself. Never store an url by=20
yourself. Create an URL with the url string, normalize it (if applicable)=
=20
then serialize it, this will solve a lot of things by itself.

5. I agree all of those cases=20

   a. The ref is not found, timeout, unavailable -> failure

   b. Recursive $ref will probably results in a stack overflow=E2=80=A6 the=
 worst=20
case being {"$id":"#A", "$ref":"#A"} -> failure

   c. The ref is not a valid schema -> failure

=20

------=_Part_1024_16560256.1331334784026
Content-Type: text/html; charset=utf-8
Content-Transfer-Encoding: quoted-printable

<div><p style=3D"margin-bottom: 0px; font-family: Arial; line-height: norma=
l; ">- As the validators uniformity matters, I would suggest to make an ope=
n json-schema test unit in order everyone to conform his validator to the s=
ame behavious (especially in tricky cases).</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
- Reading an RFC is never a pleasure, examples covering all the cases (if a=
pplicable) would strongly help (if we can join this with a common test unit=
=E2=80=A6)</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
- I opened a topic concerning the trailing slash / in json pointers (very n=
ice to have notices this)</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
- Overriding the path&nbsp;<span style=3D"color: #521f50">#/properties/anOv=
erridenPath</span>&nbsp;with the scheme {"deny":"any"}, would make the foll=
owing document invalid {"anOveridenPath":"something"}; (this could have bee=
n useful in MongoDB queries)</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; mi=
n-height: 15px; "><br></p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
For your proposal:</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
1. I do not agree again. The rfc specifies the following fallback : id rela=
tively to the url where the shema has been got, relatively to the environme=
nt. This is only a matter of building absolute paths from relative one.The =
rfc&nbsp;RFC 2396 tells how to do it, you should be able to use the java.ne=
t.URL by <span style=3D"font-family: 'Courier New'; ">URL url =3D new URL( =
"http://base.com/url" , "../relativeOne.html");</span></p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; "><span style=3D"font-family: Arial; ">Normally: </span>new URL( "htt=
p://absoluteOne.com" , "http://notARelative.com"); <span style=3D"font-fami=
ly: Arial; ">will give you</span> http://notARelative.com</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; min-height: 15px; "><br></p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
Try:&nbsp;</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; ">String environment =3D "urn:"; // your fallback scheme (you could h=
ave made a whole fallback id as well "urn:uuid:123456")</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; ">String downloadedFrom =3D "//www.domain.com/theFile.json";</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; ">downloadedFrom =3D (new URL( environment , downloadedFrom)).toStrin=
g(); // will absolutize the downloadedFrom url</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; ">String rootID =3D "#fragmentName";</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; ">rootID =3D (new URL( downloadedFrom , rootID)).toString(); // will =
absolutize the rootID</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; min-height: 15px; "><br></p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; "><span style=3D"font-family: Arial; ">-&gt; rootID should be =3D </s=
pan>urn://www.domain.com/theFile.json/#fragmentName</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
-&gt; index your schema in a dictionary under the (absolute and normalized)=
 url rootID, you are done=E2=80=A6</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
-&gt; add one more step for inner schema (where the absolute path will be t=
he rootID and the relative one the id's url)</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; min-height: 15px; "><br></p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
If your rootID has been "<span style=3D"font-family: 'Courier New'; ">http:=
//www.mickey.com/#</span>" it would simply not have been changed.</p>
<p style=3D"margin-bottom: 0px; font-family: 'Courier New'; line-height: no=
rmal; "><span style=3D"font-family: Arial; ">If the </span>downloadedFrom<s=
pan style=3D"font-family: Arial; "> has been =3D </span>""<span style=3D"fo=
nt-family: Arial; ">, we would simply omitted this step. </span>(new URL( a=
nAbsolutePath , "")).toString().equals(anAbsolutePath) <span style=3D"font-=
family: Arial; ">is</span> true.</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; mi=
n-height: 15px; "><br></p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; mi=
n-height: 15px; "><br></p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
2. Any url but no fragment path (json pointers) -&gt; no more overriding, w=
ell=E2=80=A6 not bad in some way</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
3. An id should be unique -&gt; I agree, this said it should be already the=
 case (or would you validate them all ? :-) )</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
4. a. about url normalization http://en.wikipedia.org/wiki/URL_normalizatio=
n , probably that using the URL class will get rid of this problem itself. =
Never store an url by yourself. Create an URL with the url string, normaliz=
e it (if applicable) then serialize it, this will solve a lot of things by =
itself.</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
5. I agree all of those cases&nbsp;</p><p style=3D"margin-bottom: 0px; font=
-family: Arial; line-height: normal; ">&nbsp; &nbsp;a. The ref is not found=
, timeout, unavailable -&gt; failure</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
&nbsp;&nbsp; b. Recursive $ref will probably results in a stack overflow=E2=
=80=A6 the worst case being {"$id":"#A", "$ref":"#A"} -&gt; failure</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; ">=
&nbsp;&nbsp; c. The ref is not a valid schema -&gt; failure</p>
<p style=3D"margin-bottom: 0px; font-family: Arial; line-height: normal; mi=
n-height: 15px; ">&nbsp;</p></div>
------=_Part_1024_16560256.1331334784026--

------=_Part_1023_7946879.1331334784026--