## Element Index

- `MIME-resolver`
- `attr`
- `doctype`
- `element`
- `exit`
- `ext`
- `fattr`
- `file`
- `magic`
- `mime`
- `name`
- `ns`
- `pattern`
- `pi`
- `public-id`
- `resolver`
- `xml-rule`

## Element Details

## MIME-resolver

MIME resolver description root element.

`PUBLIC "-//NetBeans//DTD MIME Resolver 1.0//EN"`

Element Content Model

`(file)+`

Referenced by

``

## xml-rule

MIME component checking XML resource header, permitting matches against XML constructs: processing instructions, document type declarations, and root element (start tag).

`PUBLIC "-//NetBeans//DTD MIME Resolver XML Rules 1.0//EN"`

It should work well for:

Well-formed document type detection
  Using: PIs, root element name and root element attributes.
DTD-constrained document detection
  Using: PIs and DOCTYPE public IDs.
NS-constrained documents
  Using: PIs and root element namespaces.

Element Content Model

`(pi*, doctype?, element?)`

Referenced by

`resolver`

## pi

Processing instructions can be tested on target and pseudo-attributes.

It should be used for in-band tagging that is specified by some accepted specification. For NetBeans-specific tagging of third party standards it is recommended to use out-of-band tagging such as `FileObject` attributes.

Declared Attributes

- `#REQUIRED CDATA target`

Element Content Model

`(attr*)`

Referenced by

`xml-rule`

## doctype

Match one of the DOCTYPE's public IDs. Use of `public-id` subelements is mutually exclusive with the attribute.

Declared Attributes

- `#IMPLIED CDATA public-id`

Element Content Model

`(public-id*)`

Referenced by

`xml-rule`

## public-id

A public ID is checked for an exact match.

Declared Attributes

- `#REQUIRED CDATA id`

Element Content Model

`EMPTY`

Referenced by

`doctype`

## element

Matches a root element by specified name, attributes or namespace.

The namespace `ns` attribute or the presence of any `ns` subelements implies that the `name` attribute represents a local element name, otherwise the `name` attribute represents a full element name ("QName"). One of the namespaces must match.

Declared Attributes

- `#IMPLIED CDATA ns`
- `#IMPLIED CDATA name`

Element Content Model

`(ns*, attr*)`

Referenced by

`xml-rule`

## ns

Test namespace equality (exact match).

Declared Attributes

- `#REQUIRED CDATA ns`

Element Content Model

`EMPTY`

Referenced by

`element`

## attr

Element attribute template, also used for pseudo-attributes in processing instructions.

The `name` attribute contains the full attribute name (QName). This is inteded to be used for documents that cannot be indentified by public ID nor root element namespace.

If `text` is specified then the attribute's normalized text must exactly match the specified text, otherwise the attribute just needs to be present.

Declared Attributes

- `#REQUIRED CDATA name`
- `#IMPLIED CDATA text`

Element Content Model

`EMPTY`

Referenced by

`pi, element`

## file

A file (resource) represents the MIME resolver input. The resource is tested on attributes obtained from lower layers (OS) such as extension, header bytes and wrapping `FileObject` attributes. Some of them must match to proceed to the `resolver` element.

Implementation Note: Lower level MIME type is obtained by `FileUtil.getMIMEType()`. It may not be retrieved by a call to `FileObject.getMIMEType` to avoid recursion. A better way to determine MIME type as assigned by the OS may be introduced in the future.

Implementation Note: All other tests are performed by calling appropriate methods on `FileObject` so there is a danger of recursion if these call `this.getMIMEType()`.

Element Content Model

`((ext | mime | magic | fattr | pattern | name)+, (resolver | exit))`

Referenced by

`MIME-resolver`

## ext

Tests resource extension for full equality. If name attribute is empty string (name=""), it matches all files without extension.

Declared Attributes

- `#REQUIRED CDATA name`

Element Content Model

`EMPTY`

Referenced by

`file`

## mime

Tests resource MIME type for equality (RFC2045) or suffix equality if it starts with '+' (RFC 3023).

Declared Attributes

- `#REQUIRED CDATA name`

Element Content Model

`EMPTY`

Referenced by

`file`

## magic

Look at initial bytes of the file and test for a complete match of masked bits. The default mask is the hexadecimal byte `FF` repeated as many times as the `hex` attribute is long. E.g. `<magic hex="0a0001" mask="FF00FF"/>`

Declared Attributes

- `#REQUIRED CDATA hex`
- `#IMPLIED CDATA mask`

Element Content Model

`EMPTY`

Referenced by

`file`

## fattr

Test on `FileObject` attributes. Matching attributes are converted to strings via `Object.toString()` and compared to the `text` attribute.

`FileObject` attributes can be used for out-of-band tagging of standard documents.

Declared Attributes

- `#REQUIRED CDATA name`
- `#REQUIRED CDATA text`

Element Content Model

`EMPTY`

Referenced by

`file`

## pattern

Search in the file for given pattern in given range. If there is an inner pattern element, it is used only if outer is fulfilled. Searching starts always from the beginning of the file. For example:

Pattern <?php in first 255 bytes

        <pattern value="<?php" range="255"/>

Pattern <HTML> or <html> in first 255 bytes and pattern <?php in first 4000 bytes.

        <pattern value="<HTML>" range="255" ignorecase="true">
            <pattern value="<?php" range="4000"/>
        </pattern>

Declared Attributes

- `#REQUIRED CDATA value`
- `#REQUIRED CDATA range`
- `#IMPLIED CDATA ignorecase`

Element Content Model

`(pattern?)`

Referenced by

`file, pattern`

## name

Compare filename with given name. For example:

Filename matches makefile, Makefile, MaKeFiLe, mymakefile, gnumakefile, makefile1, ....

        <name name="makefile" substring="true"/>

Filename exactly matches rakefile or Rakefile.

        <name name="rakefile" ignorecase="false"/>
        <name name="Rakefile" ignorecase="false"/>

Declared Attributes

- `#REQUIRED CDATA name`
- `#IMPLIED CDATA substring`
- `#IMPLIED CDATA ignorecase`

Element Content Model

`EMPTY`

Referenced by

`file`

## resolver

You may apply additional rules based on resource content. The `mime` element value is returned. Use the reserved value of `null` to indicate you are not interested in such files (same as `<exit/>`).

Declared Attributes

- `#REQUIRED CDATA mime`

Element Content Model

`(xml-rule)?`

Referenced by

`file`

## exit

Declares that this file is not recognized by this resolver. A shortcut for `<resolver mime="null"/>`. For example:

Do not resolve *.txt files and do time consuming magic recognition only for not-txt files.

        <file>
          <ext name="txt"/>
          <exit/>
        </file>
        <file>
          <magic hex="0a0001" mask="FF00FF"/>
          <resolver mime="text/plain"/>
        </file>

Element Content Model

`EMPTY`

Referenced by

`file`