private function translateCssToXpath($cssSelector)
    {
        $paddedSelector = ' ' . $cssSelector . ' ';
        $lowercasePaddedSelector = \preg_replace_callback(
            '/\\s+\\w+\\s+/',
            function (array $matches) {
                return \strtolower($matches[0]);
            },
            $paddedSelector
        );
        $trimmedLowercaseSelector = \trim($lowercasePaddedSelector);
        $xPathKey = \md5($trimmedLowercaseSelector);
        if (isset($this->caches[static::CACHE_KEY_XPATH][$xPathKey])) {
            return $this->caches[static::CACHE_KEY_SELECTOR][$xPathKey];
        }

        $hasNotSelector = (bool)\preg_match(
            '/^([^:]+):not\\(\\s*([[:ascii:]]+)\\s*\\)$/',
            $trimmedLowercaseSelector,
            $matches
        );
        if (!$hasNotSelector) {
            $xPath = '//' . $this->translateCssToXpathPass($trimmedLowercaseSelector);
        } else {
            /** @var string[] $matches */
            list(, $partBeforeNot, $notContents) = $matches;
            $xPath = '//' . $this->translateCssToXpathPass($partBeforeNot) .
                '[not(' . $this->translateCssToXpathPassInline($notContents) . ')]';
        }
        $this->caches[static::CACHE_KEY_SELECTOR][$xPathKey] = $xPath;

        return $this->caches[static::CACHE_KEY_SELECTOR][$xPathKey];
    }
private function translateCssToXpath($cssSelector)
    {
        $paddedSelector = ' ' . $cssSelector . ' ';
        $lowercasePaddedSelector = \preg_replace_callback(
            '/\\s+\\w+\\s+/',
            function (array $matches) {
                return \strtolower($matches[0]);
            },
            $paddedSelector
        );
        $trimmedLowercaseSelector = \trim($lowercasePaddedSelector);
        $xPathKey = \md5($trimmedLowercaseSelector);
        if (isset($this->caches[static::CACHE_KEY_XPATH][$xPathKey])) {
            return $this->caches[static::CACHE_KEY_SELECTOR][$xPathKey];
        }

        $hasNotSelector = (bool)\preg_match(
            '/^([^:]+):not\\(\\s*([[:ascii:]]+)\\s*\\)$/',
            $trimmedLowercaseSelector,
            $matches
        );
        if (!$hasNotSelector) {
            $xPath = '//' . $this->translateCssToXpathPass($trimmedLowercaseSelector);
        } else {
            /** @var string[] $matches */
            list(, $partBeforeNot, $notContents) = $matches;
            $xPath = '//' . $this->translateCssToXpathPass($partBeforeNot) .
                '[not(' . $this->translateCssToXpathPassInline($notContents) . ')]';
        }
        $this->caches[static::CACHE_KEY_SELECTOR][$xPathKey] = $xPath;

        return $this->caches[static::CACHE_KEY_SELECTOR][$xPathKey];
    }
private function translateCssToXpath ( $ cssSelector ) { $ paddedSelector = ' ' . $ cssSelector . ' ' ; $ lowercasePaddedSelector = \ preg_replace_callback ( '/\\s+\\w+\\s+/' , function ( array $ matches ) { return \ strtolower ( $ matches [ 0 ] ) ; } , $ paddedSelector ) ; $ trimmedLowercaseSelector = \ trim ( $ lowercasePaddedSelector ) ; $ xPathKey = \ md5 ( $ trimmedLowercaseSelector ) ; if ( isset ( $ this -> caches [ static :: CACHE_KEY_XPATH ] [ $ xPathKey ] ) ) { return $ this -> caches [ static :: CACHE_KEY_SELECTOR ] [ $ xPathKey ] ; } $ hasNotSelector = ( bool ) \ preg_match ( '/^([^:]+):not\\(\\s*([[:ascii:]]+)\\s*\\)$/' , $ trimmedLowercaseSelector , $ matches ) ; if ( ! $ hasNotSelector ) { $ xPath = '//' . $ this -> translateCssToXpathPass ( $ trimmedLowercaseSelector ) ; } else { /** @var string[] $matches */ list ( , $ partBeforeNot , $ notContents ) = $ matches ; $ xPath = '//' . $ this -> translateCssToXpathPass ( $ partBeforeNot ) . '[not(' . $ this -> translateCssToXpathPassInline ( $ notContents ) . ')]' ; } $ this -> caches [ static :: CACHE_KEY_SELECTOR ] [ $ xPathKey ] = $ xPath ; return $ this -> caches [ static :: CACHE_KEY_SELECTOR ] [ $ xPathKey ] ; }
Maps a CSS selector to an XPath query string.

@see http://plasmasturm.org/log/444/

@param string $cssSelector a CSS selector

@return string the corresponding XPath selector
Maps a CSS selector to an XPath query string .