https://github.com/namib-project/curie
Implementation of the W3C CURIE Syntax 1.0. Supports prefix mapping as well as the expansion of CURIEs and the shrinking of IRIs.
https://github.com/namib-project/curie
dart flutter
Last synced: 3 months ago
JSON representation
Implementation of the W3C CURIE Syntax 1.0. Supports prefix mapping as well as the expansion of CURIEs and the shrinking of IRIs.
- Host: GitHub
- URL: https://github.com/namib-project/curie
- Owner: namib-project
- License: mit
- Created: 2022-05-13T20:54:04.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2024-05-22T12:43:25.000Z (about 1 year ago)
- Last Synced: 2025-01-22T23:11:31.486Z (5 months ago)
- Topics: dart, flutter
- Language: Dart
- Homepage:
- Size: 30.3 KB
- Stars: 2
- Watchers: 7
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
[](https://pub.dev/packages/curie)
[](https://github.com/namib-project/curie/actions/workflows/ci.yml)
[](https://codecov.io/gh/namib-project/curie)# curie
Implementation of the [W3C CURIE Syntax 1.0](https://www.w3.org/TR/curie/),
based on Bruce Mitchener, Jr.'s [Rust crate](https://crates.io/crates/curie).CURIEs are a compact way of representing a URI, consisting of an optional prefix
and a reference, separated by a colon.
They are commonly used in JSON-LD, RDF, SPARQL, XML namespaces and other
applications.This library provides classes and methods for creating and manipulating CURIEs,
making them easier to handle in your libraries and applications.## Usage
A simple example for how to use the package can be found below and in the
`/example` folder.```dart
import 'package:curie/curie.dart';void main() {
// Initialize a prefix mapper.
final mapper = PrefixMapping()
..addPrefix("foaf", "http://xmlns.com/foaf/0.1/")
// Set a default prefix value
..defaultPrefixValue = "http://example.com/";// Prints "http://example.com/Entity"
print(mapper.expandCurieString("Entity"));// Prints "http://xmlns.com/foaf/0.1/Agent"
print(mapper.expandCurieString("foaf:Agent"));final curie = Curie(prefix: "foaf", reference: "Agent");
// Prints "http://xmlns.com/foaf/0.1/Agent"
print(mapper.expandCurie(curie));// Creates a Curie object that prints "foaf:Agent"
print(mapper.shrinkIri("http://xmlns.com/foaf/0.1/Agent"));
}
```