JSON schema cross file references using $anchor and $ref
Oxygen general issues.
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"}
}
}
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>
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
Jump to
- Oxygen XML Editor
- ↳ Announcements
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ 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 Services Market
- ↳ Offer a Service