JSON schema cross file references using $anchor and $ref
Oxygen general issues.
-
- Posts: 3
- Joined: Wed Nov 30, 2022 6:57 pm
JSON schema cross file references using $anchor and $ref
I need to reference common definitions in a number for schema, but can get it working in oxygenxml v.25.0
I've created a common.jschema file with the common $defs definition with an $achor and $id. However when I try to reference this from another schema in a $ref it can't resolve the reference. The $ref in the file my_schema,jshema gives an error "#/properties/name/$ref: ro.sync.net.protocol.http.HttpExceptionWithDetails: 404 Not Found for: https://example.com/schemas/common"
Is this supported in oxygenxl v.25.0? How do is this done?
Here are the two examples; All files are in the same directory -
common.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/common",
"$defs": {
"non-empty-string": {
"$anchor": "non-empty-string",
"type": "string",
"minLength": 1
}
}
}
my_string.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/my_string",
"type": "object",
"properties": {
"name": {"$ref": "/schemas/common#non-empty_string"}
}
}
I've created a common.jschema file with the common $defs definition with an $achor and $id. However when I try to reference this from another schema in a $ref it can't resolve the reference. The $ref in the file my_schema,jshema gives an error "#/properties/name/$ref: ro.sync.net.protocol.http.HttpExceptionWithDetails: 404 Not Found for: https://example.com/schemas/common"
Is this supported in oxygenxl v.25.0? How do is this done?
Here are the two examples; All files are in the same directory -
common.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/common",
"$defs": {
"non-empty-string": {
"$anchor": "non-empty-string",
"type": "string",
"minLength": 1
}
}
}
my_string.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/my_string",
"type": "object",
"properties": {
"name": {"$ref": "/schemas/common#non-empty_string"}
}
}
-
- Posts: 3
- Joined: Wed Nov 30, 2022 6:57 pm
Re: JSON schema cross file references using $anchor and $ref
I've resolved this issue. Here is the solution in case anyone else needs it:
Compound schema documents, where a schema refers to a schema in another file, require the URIs to be mapped to the actual shema file location
In Oxygen xml this is done using can XML Catalogue
Create an XML Catalogue file (File-> New ->XML Catalogue) called for example "catalogue.xml"
Add mapping to the file e.g. <uri name="https://example.com/schemas/common" uri="common.jschema"/>
Add this catalogue to the list of cats the Oxygenxml searches: Options-> Preferences->XML->XML Catalogue – <add the catalogue file>
Compound schema documents, where a schema refers to a schema in another file, require the URIs to be mapped to the actual shema file location
In Oxygen xml this is done using can XML Catalogue
Create an XML Catalogue file (File-> New ->XML Catalogue) called for example "catalogue.xml"
Add mapping to the file e.g. <uri name="https://example.com/schemas/common" uri="common.jschema"/>
Add this catalogue to the list of cats the Oxygenxml searches: Options-> Preferences->XML->XML Catalogue – <add the catalogue file>
-
- Posts: 387
- Joined: Thu Jul 01, 2004 12:29 pm
Re: JSON schema cross file references using $anchor and $ref
Hello,
Yes, if you have references to remote schemas you can use an XML Catalog to resolve the references locally.
There is a topic in our user manual that explains the resolving references with an XML Catalog:
https://www.oxygenxml.com/doc/versions/ ... talog.html
Best Regards,
Octavian
Yes, if you have references to remote schemas you can use an XML Catalog to resolve the references locally.
There is a topic in our user manual that explains the resolving references with an XML Catalog:
https://www.oxygenxml.com/doc/versions/ ... talog.html
Best Regards,
Octavian
Octavian Nadolu
<oXygen/> XML Editor
http://www.oxygenxml.com
<oXygen/> XML Editor
http://www.oxygenxml.com
-
- Posts: 3
- Joined: Wed Nov 30, 2022 6:57 pm
Re: JSON schema cross file references using $anchor and $ref
I've come back to this and tried to get this working again but can't. I'd like to produce a very simple example of a schema referencing a common definition schema file and using an XML catalogue to resolve the URI of the common reference to a local file in the same directory. I've tryed using the above example but can't get it working and can't find any worked example.
-
- Posts: 38
- Joined: Wed Sep 09, 2020 3:17 pm
Re: JSON schema cross file references using $anchor and $ref
Post by florin_nica »
Hello,
Oxygen does not support $anchor references. Instead, references can be resolved in JSON Schema Design Page if you add a $id value (URI fragment) to your local resource. So, all you have to do in order to have a working example is to go to common.jschema file and replace
with
Let me know if that worked for you.
Regards,
Florin
Oxygen does not support $anchor references. Instead, references can be resolved in JSON Schema Design Page if you add a $id value (URI fragment) to your local resource. So, all you have to do in order to have a working example is to go to common.jschema file and replace
Code: Select all
"$anchor": "non-empty-string"
Code: Select all
"$id": "#non-empty-string"
Regards,
Florin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service