class Translator implements TranslatorInterface

XPath expression translator interface.

This component is a port of the Python cssselect library, which is copyright Ian Bicking, see https://github.com/SimonSapin/cssselect.

Methods

__construct(ParserInterface $parser = null)

No description

static string
getXpathLiteral(string $element)

No description

string
cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::')

Translates a CSS selector to an XPath expression.

string
selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::')

Translates a parsed selector node to an XPath expression.

registerExtension(ExtensionInterface $extension)

No description

getExtension(string $name)

No description

nodeToXPath(NodeInterface $node)

No description

addCombination(string $combiner, NodeInterface $xpath, NodeInterface $combinedXpath)

No description

addFunction(XPathExpr $xpath, FunctionNode $function)

No description

addPseudoClass(XPathExpr $xpath, string $pseudoClass)

No description

addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, $value)

No description

Details

at line 51
__construct(ParserInterface $parser = null)

Parameters

ParserInterface $parser

at line 64
static string getXpathLiteral(string $element)

Parameters

string $element

Return Value

string

at line 93
string cssToXPath(string $cssExpr, string $prefix = 'descendant-or-self::')

Translates a CSS selector to an XPath expression.

Parameters

string $cssExpr
string $prefix

Return Value

string

at line 112
string selectorToXPath(SelectorNode $selector, string $prefix = 'descendant-or-self::')

Translates a parsed selector node to an XPath expression.

Parameters

SelectorNode $selector
string $prefix

Return Value

string

at line 117
Translator registerExtension(ExtensionInterface $extension)

Parameters

ExtensionInterface $extension

Return Value

Translator

at line 133
ExtensionInterface getExtension(string $name)

Parameters

string $name

Return Value

ExtensionInterface

Exceptions

ExpressionErrorException

at line 142
Translator registerParserShortcut(ParserInterface $shortcut)

Parameters

ParserInterface $shortcut

Return Value

Translator

at line 152
XPathExpr nodeToXPath(NodeInterface $node)

Parameters

NodeInterface $node

Return Value

XPathExpr

Exceptions

ExpressionErrorException

at line 164
XPathExpr addCombination(string $combiner, NodeInterface $xpath, NodeInterface $combinedXpath)

Parameters

string $combiner
NodeInterface $xpath
NodeInterface $combinedXpath

Return Value

XPathExpr

Exceptions

ExpressionErrorException

at line 176
XPathExpr addFunction(XPathExpr $xpath, FunctionNode $function)

Parameters

XPathExpr $xpath
FunctionNode $function

Return Value

XPathExpr

Exceptions

ExpressionErrorException

at line 188
XPathExpr addPseudoClass(XPathExpr $xpath, string $pseudoClass)

Parameters

XPathExpr $xpath
string $pseudoClass

Return Value

XPathExpr

Exceptions

ExpressionErrorException

at line 200
XPathExpr addAttributeMatching(XPathExpr $xpath, string $operator, string $attribute, $value)

Parameters

XPathExpr $xpath
string $operator
string $attribute
$value

Return Value

XPathExpr

Exceptions

ExpressionErrorException