Web   ·   Wiki   ·   Activities   ·   Blog   ·   Lists   ·   Chat   ·   Meeting   ·   Bugs   ·   Git   ·   Translate   ·   Archive   ·   People   ·   Donate
summaryrefslogtreecommitdiffstats
path: root/creactistore/_templates/lib/rdflib_/plugins/parsers/rdfa/transform/headabout.py~
blob: 0cf8f7a1383a539445e307ba8f3b5019f95e43e1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# -*- coding: utf-8 -*-
"""
Simple transfomer: the C{@about=""} is added to the C{<head>} and C{<body>} elements (unless something is already there).
Note that this transformer is always invoked by the parser because this behaviour is mandated by the RDFa syntax.

@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
"""

def head_about_transform(html, options):
    """
    @param html: a DOM node for the top level html element
    @param options: invocation options
    @type options: L{Options<pyRdfa.Options>}
    """
    for top in html.getElementsByTagName("head"):
        if not top.hasAttribute("about"):
            top.setAttribute("about", "")
    for top in html.getElementsByTagName("body"):
        if not top.hasAttribute("about"):
            top.setAttribute("about", "")