CSSSelector2XPath

This class converts a CSS selector that has been previously tokenize with the help of the SelectorLexer class into a XPath 1.0 query

package

Docxpresso

subpackage

Parser

Methods

Construct

__construct() 
access

public

This method parses the numeric formulas

_parseNumeric(string $numbers) : string
access

private

Arguments

$numbers

string

Response

string

Converts a single word selector (with no commas or meaningful whitespace) into a valid XPath 1.0 query

_singleWordQuery(string $word) : array|NULL
access

private

Arguments

$word

string

Response

array|NULL

The first array element is a valid XPath 1.0 query The second array entry is the specificity of that word It returns NULL if the CSS selector can not be converted into XPath, i.e. selectors that contain pseudoclasses and/or pseudoelements that have no XPath counterpart like ':active', ':visited', etcetera

This method builds the subquery associated with attribute CSS selectors

_xpathAttribute(string $operand, integer $pos, array $word) : string
access

private

Arguments

$operand

string

possible values are:'^', '$', '|', '!', '~', '*', '='

$pos

integer

$word

array

Response

string

Converts a single selector (with no commas) into a valid XPath 1.0 query

generateXPathQuery(string $selector) : array|NULL
access

public

Arguments

$selector

string

Response

array|NULL

a valid XPath 1.0 query The first array entry includes the full XPath query and the second the specificity of the corresponding selector It returns NULL if the CSS selector can not be converted into XPath, i.e. selectors that contain pseudoclasses and/or pseudoelements that have no XPath counterpart like ':active', ':visited', etcetera

Properties

instance of a SelectorLexer class

_lexer : \Docxpresso\Parser\SelectorLexer
var
access

private

Type(s)

\Docxpresso\Parser\SelectorLexer