Execute an XPath query.

@param string $pQuery XPath query
@return mixed
503130
public function xPathQuery($pQuery, $pNode = NULL)
    {
        $queryResult = $this->_getXPath()->query($pQuery, $pNode);
        if ($queryResult === false) {
            throw new Exception("Invalid XPath request");
        }

        return $queryResult;
    }
381077
public static function xpathQuery(DOMDocument $document, $query, $returnFirst = true)
    {
        $xpath = new DOMXPath($document);
        $entries = $xpath->query($query);

        if ($entries->length) {
            return $returnFirst ? $entries->item(0) : $entries;
        }
    }
226564
public function normalizeNodeQuery(NodeQuery $nodeQuery)
    {
        if($nodeQuery->getParameter('NodeQuery.normalized') == null)
        {
            $this->Events->trigger('Node.normalizeQuery', $nodeQuery);
            $nodeQuery->setParameter('NodeQuery.normalized', true);
        }

//
//        if($nodeQuery->hasParameter('NodePartials.eq') && $nodeQuery->hasParameter('NodeRefs.normalized') && $nodeQuery->hasParameter('NodeRefs.fullyQualified'))
//            return $nodeQuery;


        if(!$nodeQuery->hasParameter('NodePartials.eq'))
            $nodeQuery->setParameter('NodePartials.eq', new NodePartials($nodeQuery->getParameter('Meta.select'), $nodeQuery->getParameter('OutTags.select'), $nodeQuery->getParameter('InTags.select')));

        // NODEREFS
        if($nodeQuery->hasParameter('NodeRefs.in'))
        {
            $noderefsin = $nodeQuery->getParameter('NodeRefs.in');

            if(is_string($noderefsin)) {
                $nodeRefsIn = array();

                $noderefsin = explode(',',$noderefsin);
                foreach($noderefsin as $noderefstr)
                {
                    $noderef = $this->parseFromString(trim($noderefstr));
                    if(!empty($noderef))
                        $nodeRefsIn[] = $noderef;
                }

            } else {
                $nodeRefsIn = $noderefsin;

            }

            $nodeQuery->setParameter('NodeRefs.normalized', $nodeRefsIn);

            if(!$nodeQuery->hasParameter('NodeRefs.fullyQualified'))
                $nodeQuery->setParameter('NodeRefs.fullyQualified', true);

            return $nodeQuery;
//            return array($nodeRefsIn, $nodePartials,
//                $nodeQuery->hasParameter('NodeRefs.fullyQualified')?$nodeQuery->getParameter('NodeRefs.fullyQualified'):true);

        }



        $nodeRefs = array();

        if(!$nodeQuery->hasParameter('Elements.in'))
            throw new NodeException('Unable to query nodes without Elements.in specified');

        $elementSlugs = $nodeQuery->getParameter('Elements.in');
        if(!is_array($elementSlugs))
            $elementSlugs = StringUtils::smartExplode($elementSlugs);

//        $firstElement = null;

        $sites = array();

        if($nodeQuery->hasParameter('Sites.in')) {
            $siteSlugs = $nodeQuery->getParameter('Sites.in');
            if(!is_array($siteSlugs))
                $siteSlugs = StringUtils::smartExplode($siteSlugs);

            $sites = $this->SiteService->multiGetBySlug($siteSlugs);
        }

        $elements = array();
        foreach($elementSlugs as $ek => $elementSlug)
        {
            if(substr($elementSlug, 0, 1) == '@'){

                $aspectSlug = substr($elementSlug, 1);
                $aspect = $this->AspectService->getBySlug($aspectSlug);

                if($aspect->ElementMode == 'one' || $aspect->ElementMode == 'anchored')
                {

                    $elements = array_merge($elements, (array)$this->ElementService->findAllWithAspect($aspectSlug));
                    unset($elementSlugs[$ek]);

                } else {

                    if(!empty($sites))
                        foreach((array)$sites as $site)
                            $elements = array_merge($elements, (array)$this->ElementService->findAllWithAspect($aspectSlug, $site->getSlug()));
                    else
                        $elements = array_merge($elements, (array)$this->ElementService->findAllWithAspect($aspectSlug));

                }
            } else {

                $elements[] = $this->ElementService->getBySlug($elementSlug);
            }

        }

        if(empty($elements))
            throw new NoElementsException('No elements found for expression ['.$nodeQuery->getParameter('Elements.in').'].');


        $allFullyQualified = false;

//        $allSites = array();
//        if($nodeQuery->hasParameter('Sites.in')) {
//            $siteSlugs = $nodeQuery->getParameter('Sites.in');
//            if(!is_array($siteSlugs))
//                $siteSlugs = StringUtils::smartExplode($siteSlugs);
//
//            $allSites = $this->SiteService->multiGetBySlug($siteSlugs);
//        } else if ($nodeQuery->hasParameter('SiteIDs.in')) {
//            $siteIDs = $nodeQuery->getParameter('SiteIDs.in');
//            if(!is_array($siteIDs))
//                $siteIDs = StringUtils::smartExplode($siteIDs);
//
//            foreach($siteIDs as $siteID)
//                $allSites[] = $this->SiteService->getByID($siteID);
//
//        } else {
//            $allSites = $this->SiteService->findAll()->getResults();
//        }


        foreach($elements as $element)
        {

//            if($element->isAnchored() && $nodeQuery->getParameter('Elements.ignoreAnchoredSite') == null){
//                $sites = array($element->getAnchoredSite());
//            } else {
//                $sites = $allSites;
//            }

//            foreach($sites as $site)
//            {
                if (($slugs = $nodeQuery->getParameter('Slugs.in')) != null) {
                    if(!is_array($slugs))
                        $slugs = StringUtils::smartExplode($slugs);

                    $allFullyQualified = true;
                    foreach($slugs as $slug)
                        $nodeRefs[] = new NodeRef($element, SlugUtils::createSlug($slug, true));
                }else {
                    $nodeRefs[] = new NodeRef($element);
                }
//            }
        }


        $nodeQuery->setParameter('NodeRefs.normalized', $nodeRefs);

        //if(!$nodeQuery->hasParameter('NodeRefs.fullyQualified'))
        $nodeQuery->setParameter('NodeRefs.fullyQualified', $allFullyQualified);
        //return array($nodeRefs, $nodePartials, $allFullyQualified);
        return $nodeQuery;

    }
428514
public function xpath($query)
    {
        if ($this->ownerDocument) {
            return $this->ownerDocument->getXpath()->query($query, $this);
        }

        throw new BadMethodCallException('cannot xpath on element without an owner document');
    }
719720
public static function xpQuery(DOMNode $node, string $query) : array
    {
        static $xpCache = null;

        if ($node instanceof DOMDocument) {
            $doc = $node;
        } else {
            $doc = $node->ownerDocument;
        }

        if ($xpCache === null || !$xpCache->document->isSameNode($doc)) {
            $xpCache = new DOMXPath($doc);
            $xpCache->registerNamespace('soap-env', Constants::NS_SOAP);
            $xpCache->registerNamespace('saml_protocol', Constants::NS_SAMLP);
            $xpCache->registerNamespace('saml_assertion', Constants::NS_SAML);
            $xpCache->registerNamespace('saml_metadata', Constants::NS_MD);
            $xpCache->registerNamespace('ds', XMLSecurityDSig::XMLDSIGNS);
            $xpCache->registerNamespace('xenc', XMLSecEnc::XMLENCNS);
        }

        $results = $xpCache->query($query, $node);
        $ret = [];
        for ($i = 0; $i < $results->length; $i++) {
            $ret[$i] = $results->item($i);
        }

        return $ret;
    }
961702
function executeNonQuery($query) {

        try {
            $connection = $this->getConnection();

            if (!mysql_query($query, $connection)) {
                mysql_close($connection);
                throw new \Exception("SQL Error: " . mysql_error());
            }

            mysql_close($connection);
        } catch (\Exception $pEx) {
            throw new \Exception("Fallo al ejecutar la query: " . $query . $pEx->getMessage());
        }
    }
337452
function getQueryExecutor() {
		if (!$this->exec) {
			$this->exec = new QueryExecutor($this->conn);
		}
		return $this->exec;
	}
1159606
private function xpathQuery(string $query, DOMNode $element = null): DOMNodeList
    {
        if (null === $element) {
            $element = $this->dom()->documentElement;
        }
        if (null === $element->ownerDocument) {
            throw new \LogicException('Cannot create a XPath query on an element without document');
        }
        /** @var DOMNodeList|false $nodelist phpstan does not know that query can return false */
        $nodelist = (new DOMXPath($element->ownerDocument))->query($query, $element);
        if (false === $nodelist) {
            $nodelist = new DOMNodeList();
        }
        return $nodelist;
    }
940666
protected function execute($query)
    {
        $query->execute($this->bindings);
        
        $this->bindings = [];
        $this->wheres   = [];

        return $query;
    }
856682
private function executeQuery(QueryBuilder $qb, $document)
    {
        $identifier = $qb->class->createIdentifier($document);

        $qb->update();
        $qb->setIdentifier($identifier);

        if ($qb->class->isVersioned) {
            $versionMapping   = $qb->class->getPropertyMetadata($qb->class->versionAttribute);
            $versionAttribute = $qb->attr($versionMapping->name);
            $version          = $versionMapping->getValue($document);

            $versionAttribute->equals($version);
        }

        try {
            $qb->getQuery()->execute();
        } catch (\Aws\DynamoDb\Exception\DynamoDbException $e) {
            if ($qb->class->isVersioned && $e->getAwsErrorCode() === 'ConditionalCheckFailedException') {
                throw LockException::lockFailed($document);
            }

            throw $e;
        }
    }
955581
private function executeQuery(string $url, string $locale = null): string
    {
        if (null !== $locale) {
            $url .= '&'.http_build_query([
                'accept-language' => $locale,
            ]);
        }

        $request = $this->getRequest($url);
        $request = $request->withHeader('User-Agent', $this->userAgent);

        if (!empty($this->referer)) {
            $request = $request->withHeader('Referer', $this->referer);
        }

        return $this->getParsedResponse($request);
    }
890986
public function findByPK($pk)
    {
        $this->createQuery();
        $q = $this->getQuery();

        $q .= ' WHERE ' . $this->table() . '.' . $this->getPK()->identifier() . ' = ?';
        $this->setQuery($q);
        $this->setParams($pk);

        GapOrm::getDriver()->query($this->getQuery(), [$pk]);
        $obj = GapOrm::getDriver()->selectOnce();

        if (is_null($obj)) {
            return null;
        }

        $obj = $this->convertFromDB($obj);

        if ($obj) {
            return $obj;
        }

        return null;
    }
425825
public function query( $path, $node = NULL )
	{
		if( !$this->xPath )
			throw new Exception( 'No XML loaded yet.' );
		if( $node )
			$nodeList	= $this->xPath->query( $path, $node );
		else
			$nodeList	= $this->xPath->query( $path );
		return $nodeList;
	}
773187
public function getQuery()
    {
        $idField = $this->documentKey;

        if ($idField == null) {
            throw new QueryException('id should not be null');
        }

        $this->setQuery(sprintf('id:%s', $idField));

        return parent::getQuery();
    }
98113
def _query(self, url, xpath):
        
        return self.session.query(CachedRequest).filter(CachedRequest.url == url).filter(CachedRequest.xpath == xpath)
345712
def execute_xpath(xpath_string, sql_function, uuid, version):
    """"""
    settings = get_current_registry().settings
    with db_connect() as db_connection:
        with db_connection.cursor() as cursor:

            try:
                cursor.execute(SQL[sql_function],
                               {'document_uuid': uuid,
                                'document_version': version,
                                'xpath_string': xpath_string})
            except psycopg2.Error as e:
                exc = httpexceptions.HTTPBadRequest()
                exc.explanation = e.pgerror
                raise exc

            for res in cursor.fetchall():
                yield {'name': res[0],
                       'uuid': res[1],
                       'version': res[2],
                       'xpath_results': res[3]}
1037099
public function query($query) {
		$args = func_get_args();
		$query = array_shift($args);
		return $this->execute($query, $args);
	}