def make(self, selection):
cached = self._selector_cache.get(selection)<EOL>if cached:<EOL><INDENT>return cached<EOL><DEDENT>namespaces = self.EXSLT_NAMESPACES<EOL>self._add_parsley_ns(namespaces)<EOL>try:<EOL><INDENT>m = self.REGEX_ENDING_ATTRIBUTE.match(selection)<EOL>if m:<EOL><INDENT>cssxpath = css_to_xpath(m.group("<STR_LIT>"))<EOL>attribute = m.group("<STR_LIT>").replace('<STR_LIT:|>', '<STR_LIT::>')<EOL>cssxpath = "<STR_LIT>" % (cssxpath, attribute)<EOL><DEDENT>else:<EOL><INDENT>cssxpath = css_to_xpath(selection)<EOL><DEDENT>selector = lxml.etree.XPath(<EOL>cssxpath,<EOL>namespaces = self.namespaces,<EOL>extensions = self.extensions,<EOL>smart_strings=(self.SMART_STRINGS<EOL>or self._test_smart_strings_needed(selection)),<EOL>)<EOL><DEDENT>except tuple(self.CSSSELECT_SYNTAXERROR_EXCEPTIONS) as syntax_error:<EOL><INDENT>if self.DEBUG:<EOL><INDENT>print(repr(syntax_error), selection)<EOL>print("<STR_LIT>")<EOL><DEDENT>try:<EOL><INDENT>selector = lxml.etree.XPath(selection,<EOL>namespaces = self.namespaces,<EOL>extensions = self.extensions,<EOL>smart_strings=(self.SMART_STRINGS<EOL>or self._test_smart_strings_needed(selection)),<EOL>)<EOL><DEDENT>except lxml.etree.XPathSyntaxError as syntax_error:<EOL><INDENT>syntax_error.msg += "<STR_LIT>" % selection<EOL>raise syntax_error<EOL><DEDENT>except Exception as e:<EOL><INDENT>if self.DEBUG:<EOL><INDENT>print(repr(e), selection)<EOL><DEDENT>raise<EOL><DEDENT><DEDENT>except lxml.etree.XPathSyntaxError as syntax_error:<EOL><INDENT>syntax_error.msg += "<STR_LIT>" % selection<EOL>raise syntax_error<EOL><DEDENT>except Exception as e:<EOL><INDENT>if self.DEBUG:<EOL><INDENT>print(repr(e), selection)<EOL><DEDENT>raise<EOL><DEDENT>self._selector_cache[selection] = Selector(selector)<EOL>return self._selector_cache[selection]<EOL>
Scopes and selectors are tested in this order:
* is this a CSS selector with an appended @something attribute?
* is this a regular CSS selector?
* is this an XPath expression?

XPath expression can also use EXSLT functions (as long as they are
understood by libxslt)