host Package

host Package

Host language sub-package for the pyRdfa package. It contains variables and possible modules necessary to manage various RDFa host languages.

This module may have to be modified if a new host language is added to the system. In many cases the rdfa_core as a host language is enough, because there is no need for a special processing. However, some host languages may require an initial context, or their value may control some transformations, in which case additional data have to be added to this module. This module header contains all tables and arrays to be adapted, and the module content may contain specific transformation methods.

@summary: RDFa Host package @requires: U{RDFLib package<http://rdflib.net>} @organization: U{World Wide Web Consortium<http://www.w3.org>} @author: U{Ivan Herman<a href=”http://www.w3.org/People/Ivan/“>} @license: This software is available for use under the U{W3C® SOFTWARE NOTICE AND LICENSE<href=”http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231“>}

@var content_to_host_language: a dictionary mapping a media type to a host language @var preferred_suffixes: mapping from preferred suffixes for media types; used if the file is local, ie, there is not HTTP return value for the media type. It corresponds to the preferred suffix in the media type registration @var initial_contexts: mapping from host languages to list of initial contexts @var accept_xml_base: list of host languages that accept the xml:base attribute for base setting @var accept_xml_lang: list of host languages that accept the xml:lang attribute for language setting. Note that XHTML and HTML have some special rules, and those are hard coded... @var warn_xmlns_usage: list of host languages that should generate a warning for the usage of @xmlns (for RDFa 1.1) @var accept_embedded_rdf_xml: list of host languages that might also include RDF data using an embedded RDF/XML (e.g., SVG). That RDF data may be merged with the output @var accept_embedded_turtle: list of host languages that might also include RDF data using a C{script} element. That RDF data may be merged with the output @var require_embedded_rdf: list of languages that must accept embedded RDF, ie, the corresponding option is irrelevant @var host_dom_transforms: dictionary mapping a host language to an array of methods that are invoked at the beginning of the parsing process for a specific node. That function can do a last minute change on that DOM node, eg, adding or modifying an attribute. The method’s signature is (node, state), where node is the DOM node, and state is the L{Execution context<pyRdfa.state.ExecutionContext>}. @var predefined_1_0_rel: terms that are hardcoded for HTML+RDF1.0 and replace the initial context for that version @var beautifying_prefixes: this is really just to make the output more attractive: for each media type a dictionary of prefix-URI pairs that can be used to make the terms look better... @var default_vocabulary: as its name suggests, default @vocab value for a specific host language

class rdflib.plugins.parsers.pyRdfa.host.HostLanguage[source]

An enumeration style class: recognized host language types for this processor of RDFa. Some processing details may depend on these host languages. “rdfa_core” is the default Host Language is nothing else is defined.

__module__ = 'rdflib.plugins.parsers.pyRdfa.host'
atom = 'Atom+RDFa'
html5 = 'HTML5+RDFa'
rdfa_core = 'RDFa Core'
svg = 'SVG+RDFa'
xhtml = 'XHTML+RDFa'
xhtml5 = 'XHTML5+RDFa'
class rdflib.plugins.parsers.pyRdfa.host.MediaTypes[source]

An enumeration style class: some common media types (better have them at one place to avoid misstyping...)

__module__ = 'rdflib.plugins.parsers.pyRdfa.host'
atom = 'application/atom+xml'
html = 'text/html'
nt = 'text/plain'
rdfxml = 'application/rdf+xml'
smil = 'application/smil+xml'
svg = 'application/svg+xml'
svgi = 'image/svg+xml'
turtle = 'text/turtle'
xhtml = 'application/xhtml+xml'
xml = 'application/xml'
xmlt = 'text/xml'
rdflib.plugins.parsers.pyRdfa.host.adjust_html_version(input, rdfa_version)[source]

Adjust the rdfa_version based on the (possible) DTD @param input: the input stream that has to be parsed by an xml parser @param rdfa_version: the current rdfa_version; will be returned if nothing else is found @return: the rdfa_version, either “1.0” or “1.1, if the DTD says so, otherwise the input rdfa_version value

rdflib.plugins.parsers.pyRdfa.host.adjust_xhtml_and_version(dom, incoming_language, rdfa_version)[source]

Check if the xhtml+RDFa is really XHTML 0 or 1 or whether it should be considered as XHTML5. This is done by looking at the DTD. Furthermore, checks whether whether the system id signals an rdfa 1.0, in which case the version is also set.

@param dom: top level DOM node @param incoming_language: host language to be checked; the whole check is relevant for xhtml only. @param rdfa_version: rdfa_version as known by the caller @return: a tuple of the possibly modified host language (ie, set to XHTML5) and the possibly modified rdfa version (ie, set to “1.0”, “1.1”, or the incoming rdfa_version if nothing is found)

atom Module

Simple transfomer for Atom: the C{@typeof=“”} is added to the C{<entry>} element (unless something is already there).

@summary: Add a top “about” to <head> and <body> @requires: U{RDFLib package<http://rdflib.net>} @organization: U{World Wide Web Consortium<http://www.w3.org>} @author: U{Ivan Herman<a href=”http://www.w3.org/People/Ivan/“>} @license: This software is available for use under the U{W3C® SOFTWARE NOTICE AND LICENSE<href=”http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231“>} @contact: Ivan Herman, ivan@w3.org

rdflib.plugins.parsers.pyRdfa.host.atom.atom_add_entry_type(node, state)[source]

@param node: the current node that could be modified @param state: current state @type state: L{Execution context<pyRdfa.state.ExecutionContext>}

html5 Module

Simple transfomer for HTML5: add a @src for any @data, add a @content for the @value attribute of the <data> element, and interpret the <time> element.

@summary: Add a top “about” to <head> and <body> @requires: U{RDFLib package<http://rdflib.net>} @organization: U{World Wide Web Consortium<http://www.w3.org>} @author: U{Ivan Herman<a href=”http://www.w3.org/People/Ivan/“>} @license: This software is available for use under the U{W3C® SOFTWARE NOTICE AND LICENSE<href=”http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231“>} @contact: Ivan Herman, ivan@w3.org

rdflib.plugins.parsers.pyRdfa.host.html5.html5_extra_attributes(node, state)[source]

@param node: the current node that could be modified @param state: current state @type state: L{Execution context<pyRdfa.state.ExecutionContext>}

rdflib.plugins.parsers.pyRdfa.host.html5.remove_rel(node, state)[source]

If @property and @rel/@rev are on the same element, then only CURIE and URI can appear as a rel/rev value.

@param node: the current node that could be modified @param state: current state @type state: L{Execution context<pyRdfa.state.ExecutionContext>}