All Downloads are FREE. Search and download functionalities are using the official Maven repository.

category.xsl.performance.xml Maven / Gradle / Ivy

There is a newer version: 7.7.0
Show newest version
<?xml version="1.0" encoding="UTF-8"?>

<ruleset name="Performance"
         xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">

    <description>
Rules that flag suboptimal code.
    </description>

    <rule name="AvoidAxisNavigation"
          language="xsl"
          since="5.0"
          message="Axis navigation has the largest impact when writing an XPath query."
          class="net.sourceforge.pmd.lang.rule.xpath.XPathRule"
          externalInfoUrl="${pmd.website.baseurl}/pmd_rules_xsl_performance.html#avoidaxisnavigation">
        <description>
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.
        </description>
        <priority>3</priority>
        <properties>
            <property name="xpath">
<!-- the use of node() allow to target any node with an select attribute
     but also workaround the ambiguity of having the xsl namespace in the
     node name.-->
                <value>
<![CDATA[
//node()[
  contains(@select,'preceding::')
  or
  contains(@select,'following::')
  or
  contains(@select,'descendant::')
  or
  contains(@select,'descendant-self::')
  or (
    ($checkSelfDescendantAbreviation = true() )
    and
    contains(@select,'//')
    )
]
]]>
                </value>
            </property>
            <property name="checkSelfDescendantAbreviation" type="Boolean" description="descendant::self abreviation, '//', will also trigger this rule." value="false"/>
        </properties>
        <example>
<![CDATA[
<xsl:variable name="var" select="//item/descendant::child"/>
]]>
        </example>
    </rule>

</ruleset>




© 2015 - 2024 Weber Informatics LLC | Privacy Policy