Detect DTD (detectDTD)

<detectDTD> Element

The detectDTD rule is used to find a Document Type Definition (DTD) in XML files.

Table 1. <detectDTD> Element Attributes
Attribute Name Type Required Description
dtdName Regex Yes

The Document Type Definition (DTD) names.

rootTag String No

The root tag of the XML document.

flagNullDocTypeWhenNoVersionAttrExists Boolean No

Indicates whether to flag a null doctype when no version attribute is specified.

flagOnce Boolean No

Indicates whether to flag once per archive. Defaults to false.

flagOncePerFile Boolean No

Indicates whether to flag once per file. Defaults to false.

hideResult Boolean No

Indicates whether results flagged by this rule should be hidden in the report. This attribute only hides results when used with rules under the <and> or <or> tags. Defaults to false.

Child Elements (One or more)

<xmlFile> Element - required, can be multiple

Table 2. <xmlFile> Element Attributes
Attribute Name Type Required Description
pattern Regex Yes

File name with or without path.

For example, to detect an ejb-jar.xml file in an application's META-INF or WEB-INF directory with the DTD http://java.sun.com/j2ee/dtds/ejb-jar_1_1.dtd, specify:


<detectDTD dtdName="http://java\.sun\.com/j2ee/dtds/ejb-jar_1_1\.dtd">
    <xmlFile pattern="(.*/)?(META-INF|WEB-INF)/ejb-jar\.xml"/>
</detectDTD>