transform Package

transform Package

Transformer sub-package for the pyRdfa package. It contains modules with transformer functions; each may be invoked by pyRdfa to transform the dom tree before the “real” RDfa processing.

@summary: RDFa Transformer 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“>}

rdflib.plugins.parsers.pyRdfa.transform.empty_safe_curie(node, options, state)[source]

Remove the attributes whose value is an empty safe curie. It also adds an ‘artificial’ flag, ie, an attribute (called ‘emptysc’) into the node to signal that there _is_ an attribute with an ignored safe curie value. The name of the attribute is ‘about_pruned’ or ‘resource_pruned’.

@param node: a DOM node for the top level element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

rdflib.plugins.parsers.pyRdfa.transform.top_about(root, options, state)[source]

@param root: a DOM node for the top level element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

rdflib.plugins.parsers.pyRdfa.transform.vocab_for_role(node, options, state)[source]

The value of the @role attribute (defined separately in the U{Role Attribute Specification Lite<http://www.w3.org/TR/role-attribute/#using-role-in-conjunction-with-rdfa>}) should be as if a @vocab value to the XHTML vocabulary was defined for it. This method turns all terms in role attributes into full URI-s, so that this would not be an issue for the run-time.

@param node: a DOM node for the top level element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

DublinCore Module

Transfomer: handles the Dublin Core recommendation for XHTML for adding DC values. What this means is that:

  • DC namespaces are defined via C{<link rel=”schema.XX” value=”....”/>}
  • The ‘XX.term’ is used much like QNames in C{<link>} and C{<meta>} elements. For the latter, the namespaced names are added to a C{@property} attribute.

This transformer adds “real” namespaces and changes the DC references in link and meta elements to abide to the RDFa namespace syntax.

@summary: Dublin Core transformer @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.transform.DublinCore.DC_transform(html, options, state)[source]

@param html: a DOM node for the top level html element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

OpenID Module

Simple transfomer: handle OpenID elements. Ie: an openid namespace is added and the usual ‘link’ elements for openid are exchanged against a namespaced version.

@summary: OpenID transformer module. @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 @var OPENID_NS: the OpenID URI used in the package

rdflib.plugins.parsers.pyRdfa.transform.OpenID.OpenID_transform(html, options, state)[source]

Replace C{openid.XXX} type C{@rel} attribute values in C{<link>} elements by C{openid:XXX}. The openid URI is also added to the top level namespaces with the C{openid:} local name.

@param html: a DOM node for the top level html element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

lite Module

@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 @version: $Id: lite.py,v 1.11 2013-09-26 16:37:54 ivan Exp $ $Date: 2013-09-26 16:37:54 $

rdflib.plugins.parsers.pyRdfa.transform.lite.lite_prune(top, options, state)[source]

This is a misnomer. The current version does not remove anything from the tree, just generates warnings as for the usage of non-lite attributes. A more aggressive version would mean to remove those attributes, but that would, in fact, define an RDFa Lite conformance level in the parser, which is against the WG decisions. So this should not be done; the corresponding commands are commented in the code below...

@param top: a DOM node for the top level element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

metaname Module

Simple transfomer: C{meta} element is extended with a C{property} attribute, with a copy of the C{name} attribute values.

@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 @version: $Id: metaname.py,v 1.3 2012-01-18 14:16:45 ivan Exp $ $Date: 2012-01-18 14:16:45 $

rdflib.plugins.parsers.pyRdfa.transform.metaname.meta_transform(html, options, state)[source]

@param html: a DOM node for the top level html element @param options: invocation options @type options: L{Options<pyRdfa.options>} @param state: top level execution state @type state: L{State<pyRdfa.state>}

prototype Module

Encoding of the RDFa prototype vocabulary behavior. This means processing the graph by adding and removing triples based on triples using the rdfa:Prototype and rdfa:ref class and property, respectively. For details, see the HTML5+RDFa document.

@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 @version: $Id: prototype.py,v 1.1 2013-01-18 09:41:49 ivan Exp $ $Date: 2013-01-18 09:41:49 $

rdflib.plugins.parsers.pyRdfa.transform.prototype.handle_prototypes(graph)[source]