microdata-rdf-streaming-parser
Version:
A fast and lightweight streaming Microdata to RDF parser
60 lines (59 loc) • 2.52 kB
TypeScript
import type * as RDF from '@rdfjs/types';
import type { IItemScope } from './IItemScope';
import type { IVocabRegistry } from './IVocabRegistry';
/**
* A collection of utility functions.
*/
export declare class Util {
static readonly RDF = "http://www.w3.org/1999/02/22-rdf-syntax-ns#";
static readonly XSD = "http://www.w3.org/2001/XMLSchema#";
static readonly RDFA = "http://www.w3.org/ns/rdfa#";
private static readonly IRI_REGEX;
readonly dataFactory: RDF.DataFactory;
baseIRI: string;
constructor(dataFactory?: RDF.DataFactory, baseIRI?: string);
/**
* Check if the given IRI is valid.
* @param {string} iri A potential IRI.
* @return {boolean} If the given IRI is valid.
*/
static isValidIri(iri: string): boolean;
/**
* Create vocab terms for the given terms attribute.
*
* Relative IRIs will be based on the active vocab or baseIRI if `allowRelativeIris` is true.
*
* @param {string} terms An attribute value.
* @param {IItemScope} itemScope The active item scope.
* @param {boolean} allowRelativeIris If relative IRIs are allowed.
* @return {Term[]} The IRI terms.
*/
createVocabIris(terms: string, itemScope: IItemScope, allowRelativeIris: boolean): RDF.NamedNode[];
/**
* Get the predicates for which the given itemprop value should cause vocabulary expansion.
* @param terms An attribute value.
* @param itemScope The active item scope.
* @param vocabRegistry The active vocabulary registry.
*/
getVocabularyExpansionType(terms: string, itemScope: IItemScope, vocabRegistry: IVocabRegistry): RDF.NamedNode[];
/**
* Create a named node for the given term, which can be relative to the document base.
* @param {string} iri A term string.
* @return {Term} An RDF term, or undefined if invalid.
*/
createSubject(iri: string): RDF.NamedNode | undefined;
/**
* Create a new literal node.
* @param {string} literal The literal value.
* @param {IActiveTag} activeTag The current active tag.
* @return {Literal} A new literal node.
*/
createLiteral(literal: string, activeTag: IItemScope): RDF.Literal;
/**
* Determine the vocab IRI from a given type IRI.
* @link https://w3c.github.io/microdata-rdf/#property-uri-generation
* @param typeIri A type IRI.
* @param vocabRegistry The active vocabulary registry.
*/
deriveVocab(typeIri: string, vocabRegistry: IVocabRegistry): string;
}