Skip to content

Latest commit

 

History

History
7 lines (4 loc) · 2.75 KB

XPathQueries.md

File metadata and controls

7 lines (4 loc) · 2.75 KB
  1. //title: Queries title node to fetch title of the rendering.

  2. //*[@data-image-layer]: Queries elements that have the tag data-image-layer i.e. it extracts the top-most element of each layer. This is useful as setting 'display' attribute to 'none' at this element would result in hiding the entire layer.

  3. //* [not(ancestor-or-self::* [@data-image-layer]) and not(descendant::*[@data-image-layer])]: This query is used to find elements that are not a part of any layer and hence are to be shown only in the full image. not(ancestor-or-self::* [@data-image-layer]) queries all elements that neither themselves have the tag data-image-layer nor have any ancestors that have this tag i.e. it results in all elements not within layers. However, the entire svg is selected as 'svg' element neither has an ancestor nor itself has the tag data-image-layer. To avoid selecting the 'svg' element the additional condition to not include elements that have descendents with tag data-image-layer i.e. not(descendant::*[@data-image-layer]) is included in the query.

  4. //* [not(ancestor-or-self::* [@display]) and not(descendant::* [@display]) and (not(self::* [@data-image-layer]) or not(child::* )) and (self::* [@aria-labelledby] or self::* [@aria-label])]: This query is used to associate each element with its respective label/ description. Hence, this query should make it possible to individually access each object that has a label associated with it. [not(ancestor-or-self::* [@display]) and not(descendant::* [@display]) queries for elements that don't have the neither have the 'display' attribute (which is set to 'none'; otherwise the 'display' attribute is absent) themselves nor have the attribute in their ancestor/ descendants i.e. it queries for elements that are not hidden. not(self::* [@data-image-layer]) or not(child::* ) then ensures that the element selected is either not a layer itself or, in case it is, it does not have any children i.e. there is only one object within the layer. Finally, (self::* [@aria-labelledby] or self::* [@aria-label]) ensures that the selected element actually has a label associated with it.