NAME
rdf/parser/rdfa_core - RDFa Core 1.1 processor.
SYNOPSIS
from rdf/parser/rdfa_core import RdfaCoreParser, CurieExpander;
let parser := new RdfaCoreParser();
let quads := parser.parse_string(
"<doc xmlns:dc=\"http://purl.org/dc/terms/\" " _
"xmlns=\"http://example.com/\" " _
"about=\"http://example.com/book\" property=\"dc:title\">Moby Dick</doc>",
base: "http://example.com/",
);
let expander := new CurieExpander();
say( expander.expand("foaf:name") ); // http://xmlns.com/foaf/0.1/name
DESCRIPTION
This module implements the RDFa Core 1.1 processing model over a DOM-like document tree. RdfaCoreParser parses RDFa in generic XML documents using std/data/xml, with no host-language-specific behaviour beyond xml:lang, xml:base, and xmlns:* prefix declarations.
The HTML and XHTML host languages are provided by rdf/parser/html_rdfa and rdf/parser/xhtml_rdfa, which build on the classes exported here.
EXPORTS
Classes
CurieExpanderExpands CURIEs, SafeCURIEs, and terms to full IRIs, seeded with the RDFa 1.1 initial context. Construct with optional named arguments
iri_mappings,term_mappings,rel_rev_terms,default_vocab, andbase.expand(String value) -> String?Expands a CURIE, SafeCURIE, or IRI to an absolute IRI string, resolving relative IRIs against the base. Returns null when the value should be ignored (e.g. an unresolvable SafeCURIE). Blank node identifiers are returned unchanged.
expand_curie(String value) -> String?Expands a bare CURIE (prefix:reference). Returns null unless the prefix has a mapping.
expand_curie_or_iri(String value) -> String?The value space of
@aboutand@resource.expand_term_or_curie_or_absiri(String value, Boolean rel_rev := false) -> String?The value space of
@rel,@rev,@property,@typeof, and@datatype. Terms are matched against the term mappings (then the host rel/rev terms whenrel_revis true), then the default vocabulary. Relative IRIs are not resolved in this value space.resolve_iri(String value) -> StringResolves an IRI reference against the base.
with_prefixes(Dict extra) -> CurieExpanderwith_vocab(vocab) -> CurieExpanderwith_base(String base) -> CurieExpanderReturn derived expanders; the original is unchanged.
RdfaCoreParserAn
RdfParserfor RDFa in generic XML. Accepts the standardbaseandintoparser options plusvocab_expansion(Boolean) andvocab_loader(a function from vocabulary IRI to an array of quads).RdfaHostHost-language abstraction for generic XML. Subclassed by the HTML and XHTML host languages.
RdfaProcessorThe RDFa Core 1.1 processing engine. Normally used via the parser classes.
RdfaContextThe evaluation context threaded through element processing.
RdfaIncompleteTripleAn incomplete triple pending completion by a descendant element.
Constants
RDFA_NS, XHV_NS, RDFA_INITIAL_PREFIXES, and RDFA_INITIAL_TERMS.
COPYRIGHT AND LICENCE
rdf/parser/rdfa_core is copyright Toby Inkster.
It is free software; you may redistribute it and/or modify it under the terms of either the Artistic License 1.0 or the GNU General Public License version 2.