A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.pmd-code.org/latest/pmd_rules_xsl_performance.html below:

Performance | PMD Source Code Analyzer

Rules that flag suboptimal code.

Table of Contents AvoidAxisNavigation

Since: PMD 5.0

Priority: Medium (3)

Avoid using the ‘following’ or ‘preceding’ axes whenever possible, as these can cut through 100% of the document in the worst case. Also, try to avoid using ‘descendant’ or ‘descendant-or-self’ axes, as if you’re at the top of the Document, it necessarily means cutting through 100% of the document.

This rule is defined by the following XPath expression:

//node()[
  contains(@select,'preceding::')
  or
  contains(@select,'following::')
  or
  contains(@select,'descendant::')
  or
  contains(@select,'descendant-self::')
  or (
    ($checkSelfDescendantAbreviation = true() )
    and
    contains(@select,'//')
    )
]

Example(s):

<xsl:variable name="var" select="//item/descendant::child"/>

This rule has the following properties:

Name Default Value Description checkSelfDescendantAbreviation false descendant::self abreviation, ‘//’, will also trigger this rule.

Use this rule with the default properties by just referencing it:

<rule ref="category/xsl/performance.xml/AvoidAxisNavigation" />

Use this rule and customize it:

<rule ref="category/xsl/performance.xml/AvoidAxisNavigation">
    <properties>
        <property name="checkSelfDescendantAbreviation" value="false" />
    </properties>
</rule>

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4