pyRdfa.transform.metaname
Simple transfomer: C{meta} element is extended with a C{property} attribute, with a copy of the C{name} attribute values.
1# -*- coding: utf-8 -*- 2""" 3Simple transfomer: C{meta} element is extended with a C{property} attribute, with a copy of the 4C{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 8U{W3C® SOFTWARE NOTICE AND LICENSE<href="http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231">} 9@contact: Ivan Herman, ivan@w3.org 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 14def 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"))
def
meta_transform(html, options, _state):
15def meta_transform(html, options, _state): 16 """ 17 @param html: a DOM node for the top level html element 18 @param options: invocation options 19 @type options: L{Options<pyRdfa.options>} 20 @param state: top level execution state 21 @type state: L{State<pyRdfa.state>} 22 """ 23 from ..host import HostLanguage 24 if not(options.host_language in [HostLanguage.xhtml, HostLanguage.html5, HostLanguage.xhtml5]): 25 return 26 27 for meta in html.getElementsByTagName("meta"): 28 if meta.hasAttribute("name") and not meta.hasAttribute("property"): 29 meta.setAttribute("property", meta.getAttribute("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>}