modules/rdf/parser/rdfa_core.zzm

rdf-rdfa-0.0.1 documentation

Package

Name
rdf-rdfa
Version
0.0.1
Uploaded
2026-06-13 00:17:04
Repository
https://github.com/tobyink/zuzu-rdf-rdfa
Dependencies
Metadata
zuzu-distribution.json
Archive
Download .tar.gz

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

  • CurieExpander

    Expands 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, and base.

    • 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 @about and @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 when rel_rev is true), then the default vocabulary. Relative IRIs are not resolved in this value space.

    • resolve_iri(String value) -> String

      Resolves an IRI reference against the base.

    • with_prefixes(Dict extra) -> CurieExpander
    • with_vocab(vocab) -> CurieExpander
    • with_base(String base) -> CurieExpander

      Return derived expanders; the original is unchanged.

  • RdfaCoreParser

    An RdfParser for RDFa in generic XML. Accepts the standard base and into parser options plus vocab_expansion (Boolean) and vocab_loader (a function from vocabulary IRI to an array of quads).

  • RdfaHost

    Host-language abstraction for generic XML. Subclassed by the HTML and XHTML host languages.

  • RdfaProcessor

    The RDFa Core 1.1 processing engine. Normally used via the parser classes.

  • RdfaContext

    The evaluation context threaded through element processing.

  • RdfaIncompleteTriple

    An 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.