Link: start Link: parent Link: First page in set (first) Link: Previous page (previous) Link: Next page (next) Link: Last page in set (last) Link: A plain text version of this page (alternate) Link: The XIST source of this page (alternate) Link: The Python module described in this page (alternate) XIST.css ======== CSS related funtions ==================== Home > Python software > ll.xist > css Text · XIST · Python Python softwarelist of projects * ll.xistAn extensible XML/HTML generator * ExamplesParsing/creating/modifying XML; Traversing XML trees * HowtoExplains parsing/generating XML files, XML transformations via XIST classes and other basic concepts. * SearchingHow to iterate through XIST trees * TransformationHow to transform XIST trees * Advanced topicsPool chaining, converter contexts, validation * MiscellaneousExplains various odds and ends of XIST * xscXIST core classes * nsPackage containing namespace modules * parseParsing XML * presentScreen output of XML trees * simsSimple schema validation * xfindTree iteration and filtering * cssCSS related functions * scriptsScripts for text conversion and creating XIST namespaces * HistoryChangeLog for XIST * InstallationHow to install and configure XIST * MigrationHow to update your code to new versions of XIST * Mailing listsHow to subscribe to the XIST mailing lists * ll.ul4cA templating language * ll.urlRFC 2396 compliant URLs * ll.makeObject oriented make replacement * ll.daemonForking daemon processes * ll.sisyphusWriting cron jobs with Python * ll.colorRGB color values and color model conversion * ll.miscMisc utility functions and classes * ll.orasqlUtilities for cx_Oracle * ll.nightshadeServe the output of Oracle functions/procedures with CherryPy * ll.scriptsScripts for UL4 template rendering and URL handling * AploraLogging Apache HTTP requests to an Oracle database * PycocoPython code coverage * DownloadLinks to Windows and Linux, source and binary distributions * Source codeAccess to the Mercurial repositories This module contains functions related to the handling of CSS. def _isstyle(path): ==================== def replaceurls(stylesheet, replacer): ======================================= Replace all URLs appearing in the CSSStyleSheet stylesheet. For each URL the function replacer will be called and the URL will be replaced with the result. def geturls(stylesheet): ========================= Return a list of all URLs appearing in the CSSStyleSheet stylesheet. def _getmedia(stylesheet): =========================== def _doimport(wantmedia, parentsheet, base): ============================================= def iterrules(node, base=None, media=None, title=None): ======================================================== Return an iterator for all CSS rules defined in the HTML tree node. This will parse the CSS defined in any html.style or html.link element (and recursively in those stylesheets imported via the @import rule). The rules will be returned as CSSStyleRule objects from the cssutils package (so this requires cssutils). The base argument will be used as the base URL for parsing the stylesheet references in the tree (so None means the URLs will be used exactly as they appear in the tree). All URLs in the style properties will be resolved. If media is given, only rules that apply to this media type will be produced. title can be used to specify which stylesheet group should be used. If title is None only the persistent and preferred stylesheets will be used. If title is a string only the persistent stylesheets and alternate stylesheets with that style name will be used. For a description of "persistent", "preferred" and "alternate" stylesheets see def applystylesheets(node, base=None, media=None, title=None): =============================================================== applystylesheets modifies the XIST tree node by removing all CSS (from html.link and html.style elements and their @imported stylesheets) and puts the resulting style properties into the style attribute of every affected element instead. For the meaning of base, media and title see iterrules. def _is_nth_node(iterator, node, index): ========================================= def _is_nth_last_node(iterator, node, index): ============================================== def _children_of_type(node, type): =================================== class CSSWeightedSelector(ll.xist.xfind.Selector): =================================================== Base class for all CSS pseudo-class selectors. class CSSHasAttributeSelector(CSSWeightedSelector): ==================================================== A CSSHasAttributeSelector selector selects all element nodes that have an attribute with the specified XML name. def __init__(self, attributename): =================================== def matchpath(self, path): =========================== def __str__(self): =================== class CSSAttributeListSelector(CSSWeightedSelector): ===================================================== A CSSAttributeListSelector selector selects all element nodes where an attribute with the specified XML name has the specified word among the white space-separated list of words in the attribute value. def __init__(self, attributename, attributevalue): =================================================== def matchpath(self, path): =========================== def __str__(self): =================== class CSSAttributeLangSelector(CSSWeightedSelector): ===================================================== A CSSAttributeLangSelector selector selects all element nodes where an attribute with the specified XML name either is exactly the specified value or starts with the specified value followed by "-". def __init__(self, attributename, attributevalue): =================================================== def matchpath(self, path): =========================== def __str__(self): =================== class CSSFirstChildSelector(CSSWeightedSelector): ================================================== A CSSFirstChildSelector selector selects all element nodes that are the first child of its parent. def matchpath(self, path): =========================== def __str__(self): =================== class CSSLastChildSelector(CSSWeightedSelector): ================================================= A CSSLastChildSelector selector selects all element nodes that are the last child of its parent. def matchpath(self, path): =========================== def __str__(self): =================== class CSSFirstOfTypeSelector(CSSWeightedSelector): =================================================== A CSSLastChildSelector selector selects all element nodes that are the first of its type among their siblings. def matchpath(self, path): =========================== def __str__(self): =================== class CSSLastOfTypeSelector(CSSWeightedSelector): ================================================== A CSSLastChildSelector selector selects all element nodes that are the last of its type among their siblings. def matchpath(self, path): =========================== def __str__(self): =================== class CSSOnlyChildSelector(CSSWeightedSelector): ================================================= A CSSOnlyChildSelector selector selects all element nodes that are the only element among its siblings. def matchpath(self, path): =========================== def __str__(self): =================== class CSSOnlyOfTypeSelector(CSSWeightedSelector): ================================================== A CSSOnlyOfTypeSelector selector selects all element nodes that are the only element of its type among its siblings. def matchpath(self, path): =========================== def __str__(self): =================== class CSSEmptySelector(CSSWeightedSelector): ============================================= A CSSEmptySelector selector selects all element nodes that are empty (i.e. they contain no elements or non-whitespace text). def matchpath(self, path): =========================== def __str__(self): =================== class CSSRootSelector(CSSWeightedSelector): ============================================ A CSSRootSelector selector selects the root element. def matchpath(self, path): =========================== def __str__(self): =================== class CSSLinkSelector(CSSWeightedSelector): ============================================ A CSSLinkSelector selector selects all HTML links. def matchpath(self, path): =========================== def __str__(self): =================== class CSSInvalidPseudoSelector(CSSWeightedSelector): ===================================================== def matchpath(self, path): =========================== def __str__(self): =================== class CSSHoverSelector(CSSInvalidPseudoSelector): ================================================== class CSSActiveSelector(CSSInvalidPseudoSelector): =================================================== class CSSVisitedSelector(CSSInvalidPseudoSelector): ==================================================== class CSSFocusSelector(CSSInvalidPseudoSelector): ================================================== class CSSAfterSelector(CSSInvalidPseudoSelector): ================================================== class CSSBeforeSelector(CSSInvalidPseudoSelector): =================================================== class CSSFunctionSelector(CSSWeightedSelector): ================================================ Base class of all CSS selectors that require an argument. def __init__(self, value=None): ================================ def __str__(self): =================== class CSSNthChildSelector(CSSFunctionSelector): ================================================ A CSSNthChildSelector selector selects all element node that are the n-th element among their siblings. def matchpath(self, path): =========================== class CSSNthLastChildSelector(CSSFunctionSelector): ==================================================== A CSSNthLastChildSelector selector selects all element node that are the n-th last element among their siblings. def matchpath(self, path): =========================== class CSSNthOfTypeSelector(CSSFunctionSelector): ================================================= A CSSNthOfTypeSelector selector selects all element nodes that are the n-th of its type among their siblings. def matchpath(self, path): =========================== class CSSNthLastOfTypeSelector(CSSFunctionSelector): ===================================================== A CSSNthOfTypeSelector selector selects all element nodes that are the n-th last of its type among their siblings. def matchpath(self, path): =========================== class CSSTypeSelector(ll.xist.xfind.Selector): =============================================== def __init__(self, type=None, xmlns=None, *selectors): ======================================================= def matchpath(self, path): =========================== def __str__(self): =================== class CSSAdjacentSiblingCombinator(ll.xist.xfind.BinaryCombinator): ==================================================================== A CSSAdjacentSiblingCombinator works similar to an AdjacentSiblingCombinator except that only preceding elements are considered. def matchpath(self, path): =========================== def __str__(self): =================== class CSSGeneralSiblingCombinator(ll.xist.xfind.BinaryCombinator): =================================================================== A CSSGeneralSiblingCombinator works similar to an GeneralSiblingCombinator except that only preceding elements are considered. def matchpath(self, path): =========================== def __str__(self): =================== def selector(selectors, prefixes=None): ======================================== Create a walk filter that will yield all nodes that match the specified CSS expression. selectors can be a string or a cssutils.css.selector.Selector object. prefixes may be a mapping mapping namespace prefixes to namespace names. def parsestring(data, base=None, encoding=None): ================================================= Parse the string data into a cssutils stylesheet. base is the base URL for the parsing process, encoding can be used to force the parser to use the specified encoding. def parsestream(stream, base=None, encoding=None): =================================================== Parse a cssutils stylesheet from the stream stream. base is the base URL for the parsing process, encoding can be used to force the parser to use the specified encoding. def parsefile(filename, base=None, encoding=None): =================================================== Parse a cssutils stylesheet from the file named filename. base is the base URL for the parsing process (defaulting to the filename itself), encoding can be used to force the parser to use the specified encoding. def parseurl(name, base=None, encoding=None, *args, **kwargs): =============================================================== Parse a cssutils stylesheet from the URL name. base is the base URL for the parsing process (defaulting to the final URL of the response, i.e. including redirects), encoding can be used to force the parser to use the specified encoding. arg and kwargs are passed on to URL.openread, so you can pass POST data and request headers. def write(stylesheet, stream, base=None, encoding=None): =========================================================