| 1 |
|
| 2 |
""" |
| 3 |
Simple transfomer: C{meta} element is extended with a C{property} attribute, with a copy of the |
| 4 |
C{name} attribute values. |
| 5 |
|
| 6 |
@author: U{Ivan Herman<a href="http://www.w3.org/People/Ivan/">} |
| 7 |
@license: This software is available for use under the |
| 8 |
U{W3C® SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">} |
| 9 |
@contact: Ivan Herman, [email protected] |
| 10 |
@version: $Id: metaname.py,v 1.3 2012-01-18 14:16:45 ivan Exp $ |
| 11 |
$Date: 2012-01-18 14:16:45 $ |
| 12 |
""" |
| 13 |
|
| 14 |
def meta_transform(html, options, _state): |
| 15 |
""" |
| 16 |
@param html: a DOM node for the top level html element |
| 17 |
@param options: invocation options |
| 18 |
@type options: L{Options<pyRdfa.options>} |
| 19 |
@param state: top level execution state |
| 20 |
@type state: L{State<pyRdfa.state>} |
| 21 |
""" |
| 22 |
from ..host import HostLanguage |
| 23 |
if not(options.host_language in [HostLanguage.xhtml, HostLanguage.html5, HostLanguage.xhtml5]): |
| 24 |
return |
| 25 |
|
| 26 |
for meta in html.getElementsByTagName("meta"): |
| 27 |
if meta.hasAttribute("name") and not meta.hasAttribute("property"): |
| 28 |
meta.setAttribute("property", meta.getAttribute("name")) |
| 29 |
|