-
-
Notifications
You must be signed in to change notification settings - Fork 296
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Split "id" into "$base" and "$anchor". #155
Conversation
This is intended to separate the two use cases of "id" in order to simplify the definition of each keyword and clarify the intent of schema authors. Additionally, use the "$" prefix for core keywords, as already discussed in the prior decision to change "id" to "$id".
Assuming $anchor would not change resolution scope and $base can be used in the root of the document? |
|
Since Maybe you can help me understand the proposal by explaining what happens in the following example. If { "$base": "http://bar.baz",
"$anchor": "a" } Then which of the references in the following schema would we expect to be resolved, and why? { "definitions":
{ "a": { "$ref": "http://foo.bar" },
"b": { "$ref": "http://foo.bar#a" },
"c": { "$ref": "http://bar.baz" },
"d": { "$ref": "http://bar.baz#a" } }
} |
@scranen all of those I did not intend to break or change any functionality, just reorganize it, so if it looks like I broke something that's a bug in my write-up. Let me know where the confusing language is. |
The new text only says that I believe that the mechanism you propose would work, but I have a couple of remarks:
|
I agree with @scranen. It also means that $base is confusing and it's better to stick with $id. |
@scranen I think that most or all the things you are worried about are already covered in the "Internal References" and "External References" sections. Can you take a look at those and tell me where they are inadequate? In particular:
The correct restriction is that no two unequal subschemas may define the same
(assuming $base does not already have a fragment, which it SHOULD not). |
@epoberezkin we're working through a few wording issues here and have spent only a few hours on it. It's premature to declare the whole thing confusing, particularly given the epic amounts of confusion |
I've proposed something like $base before, but I tend to think it would make things more complex and not less complex. If we need it, I would like to consider calling one of the keywords "$self" instead, which would let you assign the document a URI without changing the URI base. |
That is already covered- Again, this is not new, it's exactly the same as it was under |
@awwright would your |
Also why the resistance to having an anchor naming feature which is common in other media types? |
@handrews I briefly forgot what that was referring to, sorry... XML and now HTML let you refer to any element with an
Do you think this suffices, or do we still need a new keyword? |
@awwright I found it confusing that If XML and HTML have an equally confusing multi-purpose id, I guess I'll give up on this. I think it's a horrible idea, but if it's already ratified in other standards I can't fight that. |
@awwright wait... now I'm forgetting things. HTML ids are not necessarily URIs and do not also change the base. As far as I can tell from literally two minutes with the xml:id spec, neither is it. So I'm back to wanting two keywords, although perhaps I have the names wrong. |
OK, to re-summarize. I think that there are two use cases here, and I think that HTML and XML have separate keywords/elements for them. One is defining a document-local identifier, and the other is changing the base URI. If I am right about that, I would like for JSON Schema to follow that pattern. It makes much more sense than overloading one keyword with both functions. I do not much care what the names are as long as there are two- if we use the names from HTML and XML that's great, but I'm open to whatever. If I'm wrong about HTML and XML handling these separately, I'm wrong and I probably have no case :-) |
Hmm, I think I'm starting to understand where some of the difference in perspective is coming from. The Web isn't just a collection of documents anymore, but a collection of resources. And in the Web, resources can have URIs just as well as documents can. Non-information resources don't have representations as documents, but we can say things about them, inside documents. This concept was enthusiastically embraced by RDF, RDFa, Turtle, and others; and is now seeing adoption by JSON technologies now like JSON-LD. So while HTML documents have traditionally allowed you to create resources with fragment ids (by using the "id" attribute), that's not an absolute limitation. HTML+RDFa lets you define resources with their own URIs outright. JSON-LD also allows description of multiple resources in a single document. Anticipating a vast ecosystem of schemas, JSON Schema went this direction. So if you want the traditional form where all the described resources (schemas) share the same base URI, all you have to do is prepend a "#" to the "id" argument. I think if we just make it clear that we're using URIs as ids, instead of document-local identifiers exclusively, things become a lot more intuitive. So having a separate "anchor" keyword... it just seems like three extra characters I have to type (if |
Could you please tell what they are, in the real world, not in theoretic XML land.
HTML has baseURI. I never knew it exists, I don't know why would anyone use it. The fact that XML and HTML have it doesn't mean they are used. Why do we bring lots of useless stuff in the standard? What is the real use case for it? JSON was purposefully designed as a much simpler thing than XML, there are many concepts in XML that don't exist in JSON. That was the main reason for its widespread adoption. Why do we need to copy useless abstractions from XML instead of only having things that are needed by 90% of users and not having things that are only needed by 10% (maybe even less than 1% in this case)? We already know that base URI change is exactly where implementations lack interoperability. What sense does it make to make it more complex instead of removing it completely? |
@epoberezkin: I think those are good things to talk about. Since this is closed, want to bring up these concerns on Issue #14? |
This shows how #149 could be addressed. I wrote it quickly as an example, so if we go this route it probably needs some tweaking. It just seemed more clear and concise to put this up rather than try to go into more detail in the issue.
This is intended to separate the two use cases of "id" in order to simplify
the definition of each keyword and clarify the intent of schema authors.
Additionally, use the "$" prefix for core keywords, as already discussed
in the prior decision to change "id" to "$id".