Implementation:AKSW RDFUnit Schema Discovery
| Knowledge Sources | |
|---|---|
| Domains | Semantic_Web, Schema_Discovery, Vocabulary_Management |
| Last Updated | 2026-10-16 00:00 GMT |
Overview
Concrete utility for populating the SchemaService registry from multiple sources: LOV cache, schema declaration files, standard bundled vocabularies, and dataset namespace introspection.
Description
The RDFUnitUtils class provides static methods for schema discovery, and NamespaceStatistics extracts namespace usage from a dataset's SPARQL endpoint. Together they populate the global `SchemaService` with prefix-to-namespace mappings that enable schema source resolution.
Key methods:
- fillSchemaServiceFromLOV(): Loads the bundled `schemaLOV.csv` resource containing LOV registry entries.
- fillSchemaServiceFromSchemaDecl(): Loads the bundled `schemaDecl.csv` with manual schema declarations.
- fillSchemaServiceFromFile(): Loads a custom CSV file with schema declarations (prefix, uri, optional schema URI).
- fillSchemaServiceWithStandardVocabularies(): Scans bundled vocabulary files in `org/aksw/rdfunit/vocabularies/` and registers them via `vann:preferredNamespacePrefix` annotations.
- augmentWithOwlImports():** Given a set of schema sources, transitively follows `owl:imports` to discover additional schemas.
The SchemaService is a static registry that maps prefixes and URIs to `SchemaSource` objects, used throughout the validation pipeline.
Usage
- CLI auto-discovery: Called by `ValidateCommand` when no `-s` schema prefixes are provided.
- Explicit schema loading: Called by `ValidateCommand.loadSchemaDecl()` to load bundled declarations.
- owl:imports augmentation:*** Called when `-i` flag is set to include transitively imported schemas.
Code Reference
Source Location
- Repository: AKSW/RDFUnit
- File: rdfunit-core/src/main/java/org/aksw/rdfunit/utils/RDFUnitUtils.java, rdfunit-core/src/main/java/org/aksw/rdfunit/sources/SchemaService.java, rdfunit-core/src/main/java/org/aksw/rdfunit/statistics/NamespaceStatistics.java
Signature
public final class RDFUnitUtils {
public static void fillSchemaServiceFromLOV() throws IOException;
public static void fillSchemaServiceFromSchemaDecl() throws IOException;
public static void fillSchemaServiceFromFile(String csvPath) throws IOException;
public static void fillSchemaServiceWithStandardVocabularies() throws IOException;
public static List<SchemaSource> augmentWithOwlImports(Set<SchemaSource> originalSources);
}
public final class SchemaService {
public static void addSchemaDecl(String prefix, String uri);
public static void addSchemaDecl(String prefix, String uri, String schemaUri);
public static Optional<SchemaSource> getSourceFromUri(String uri);
public static Optional<SchemaSource> getSourceFromPrefix(String prefix);
public static Collection<SchemaSource> getSourceList();
}
Import
import org.aksw.rdfunit.utils.RDFUnitUtils;
import org.aksw.rdfunit.sources.SchemaService;
I/O Contract
Inputs
| Name | Type | Required | Description |
|---|---|---|---|
| csvPath | String | No | Path to custom schema declaration CSV file |
| originalSources | Set<SchemaSource> | Yes | Initial schema set for owl:imports augmentation |
Outputs
| Name | Type | Description |
|---|---|---|
| SchemaService | Static registry | Populated with prefix→namespace→SchemaSource mappings |
Usage Examples
Load All Bundled Schemas
import org.aksw.rdfunit.utils.RDFUnitUtils;
// Load LOV cache, schema declarations, and standard vocabularies
RDFUnitUtils.fillSchemaServiceFromLOV();
RDFUnitUtils.fillSchemaServiceFromSchemaDecl();
RDFUnitUtils.fillSchemaServiceWithStandardVocabularies();
// Now SchemaService can resolve prefixes to schema sources
Optional<SchemaSource> skos = SchemaService.getSourceFromPrefix("skos");
Augment with owl:imports
import org.aksw.rdfunit.utils.RDFUnitUtils;
import java.util.Set;
// Given initial schemas, discover all transitively imported schemas
Set<SchemaSource> initialSchemas = ...;
List<SchemaSource> allSchemas = RDFUnitUtils.augmentWithOwlImports(initialSchemas);
// allSchemas includes initial + all owl:imports targets