Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions src/main/java/org/spdx/tools/schema/OwlToJsonContext.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,10 +82,12 @@ public ObjectNode convertToContext() {
ExtendedIterator<OntProperty> iter = model.listAllOntProperties();
while (iter.hasNext()) {
OntProperty property = iter.next();
String propNamespace = uriToNamespace(property.getURI());
String propName = uriToPropName(property.getURI());
String id = propNamespace + propName;
sortedOntProperties.put(id, property);
if (property.isURIResource()) {
String propNamespace = uriToNamespace(property.getURI());
String propName = uriToPropName(property.getURI());
String id = propNamespace + propName;
sortedOntProperties.put(id, property);
}
}
for (Entry<String, OntProperty> ontPropEntry:sortedOntProperties.entrySet()) {
String propNamespace = uriToNamespace(ontPropEntry.getValue().getURI());
Expand Down
18 changes: 10 additions & 8 deletions src/main/java/org/spdx/tools/schema/OwlToJsonSchema.java
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ public ObjectNode convertToJsonSchema() {
ExtendedIterator<Ontology> ontologyIter = model.listOntologies();
if (ontologyIter.hasNext()) {
Ontology ont = ontologyIter.next();
String version = ont.getVersionInfo();
String ontologyUri = version == null ? ont.getURI() : ont.getURI() + "/" + version;
if (Objects.nonNull(ontologyUri)) {
root.put("$id", ontologyUri);
}
String title = ont.getLabel(null);
if (Objects.nonNull(title)) {
root.put("title", title);
if (ont.isURIResource()) {
String version = ont.getVersionInfo();
String ontologyUri = version == null ? ont.getURI() : ont.getURI() + "/" + version;
if (Objects.nonNull(ontologyUri)) {
root.put("$id", ontologyUri);
}
String title = ont.getLabel(null);
if (Objects.nonNull(title)) {
root.put("title", title);
}
}
}
root.put(JSON_RESTRICTION_TYPE,JSON_TYPE_OBJECT);
Expand Down
3 changes: 3 additions & 0 deletions src/main/java/org/spdx/tools/schema/OwlToXsd.java
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,9 @@ public OwlToXsd(OntModel model) {
}

public XmlSchema convertToXsd() throws XmlSchemaSerializerException, SchemaException {
if (!ontology.isURIResource()) {
throw new SchemaException("Ontology is not a URI resource");
}
String nameSpace = ontology.getURI();
XmlSchema schema = new XmlSchema(nameSpace, schemas);
schema.setSchemaNamespacePrefix(nameSpace);
Expand Down