{-# LANGUAGE OverloadedStrings #-} {-# LANGUAGE TypeFamilies #-} {-# LANGUAGE FlexibleContexts #-} -- | Description: Parser for jQuery/CSS selector syntax -- -- This module provides functions for parsing jQuery/CSS selectors into -- 'Axis' functions. -- -- The following selectors are currently supported: -- -- - __Any selector__ (@*@): Select any node. -- - __Element name selector__ (@div@): Select all elements of the given -- element name. -- - __Descendant selector__ (@a b@): Select /descendants/ of all the nodes -- matching the LHS selector that match the RHS selector. -- - __Child selector__ (@a > b@): Select /children/ of all the nodes -- matching the LHS selector that match the RHS selector. -- - __Following sibling selector__ (@a ~ b@): Select /siblings/ of all the -- nodes matching the LHS selector that match the RHS selector. -- - __Adjacent sibling selector__ (@a + b@): -- Select /directly adjacent siblings/ of all the nodes matching the LHS -- selector that match the RHS selector. -- - __Alternative selector__ (@a , b@): Select all nodes that match the LHS -- selector, and also all the nodes that match the RHS selector. -- - __Class selector__ (@.classname@): Select all elements whose @class@ -- attribute contains the given class name. -- - __ID selector__ (@#id@): Select the element whose @id@ attribute matches -- the given ID. Note that while in a well-formed XML document, each ID may -- only be used once, this selector will happily return multiple nodes if the -- target document is not well-formed, or when it is combined with other -- selectors that cause the same element to be matched via multiple paths -- (see also the note below). -- - __Attribute-exists selector__ (@[attr]@): Select elements that have an -- attribute of the given name. -- - __Attribute-is selector__ (@[attr="value"]@): Select elements whose @attr@ -- attribute is exactly equal to the given value. -- - __Attribute-is-not selector__ (@[attr!="value"]@): Select elements whose -- @attr@ attribute is not exactly equal to the given value. -- - __Attribute-starts-with selector__ (@[attr^="value"]@): Select elements whose @attr@ -- attribute begins with the given value. -- - __Attribute-ends-with selector__ (@[attr$="value"]@): Select elements whose @attr@ -- attribute ends with the given value. -- - __Attribute-contains selector__ (@[attr*="value"]@): Select elements whose @attr@ -- attribute contains the given value. -- - __Attribute-contains-word selector__ (@[attr~="value"]@): Select elements -- whose @attr@ attribute contains the given value between word boundaries. -- Word boundaries are the very beginning and end of the value, as well as -- any nonzero number of whitespace characters. -- - __Attribute-contains-prefix selector__ (@[attr|="value"]@): Select elements whose @attr@ -- attribute contains the given value as a prefix. A prefix is either the -- entire value itself, or the given value plus a hyphen-minus character -- (@-@) at the very beginning of the attribute value. -- - __Not selector__ (@:not(a)@): Select all elements that do not match the -- argument selector. -- - __Has selector__ (@:has(a)@): Select all elements that have relatives -- that match the argument selector. A relationship (@+@, @~@, @>@) can be -- given at the start of the argument; if none is given, the /descendant/ -- relationship is the default. -- - __First-child selector__ (@:first-child@): Select all elements that are -- the first child of their respective parent. -- - __Last-child selector__ (@:last-child@): Select all elements that are -- the last child of their respective parent. -- - __Nth-child selector__ (@:nth-child(n)@): Select all elements that are -- the n-th child (1-based) of their respective parent. -- - __Nth-last-child selector__ (@:nth-last-child(n)@): Select all elements -- that are the n-th last child (1-based) of their respective parent. -- -- __Note__: The way the 'Axis' and 'Cursor' types work, we cannot avoid -- matching the same node multiple times - this is mainly because there is no -- 'Eq' instance for 'Cursor', and thus we cannot remove duplicate matches from -- the output of an 'Axis'. For example, the element @\