Package org.jsoup.nodes

## Class DocumentType

- java.lang.Object
- - org.jsoup.nodes.Node
  - - org.jsoup.nodes.DocumentType

All Implemented Interfaces:
  `java.lang.Cloneable`

    public class DocumentType
    extends Node

A `<!DOCTYPE>` node.

### Field Summary

Fields
`static java.lang.String` `PUBLIC_KEY`
`static java.lang.String` `SYSTEM_KEY`

### Constructor Summary

Constructors
`DocumentType​(java.lang.String name, java.lang.String publicId, java.lang.String systemId)` Create a new doctype element.

### Method Summary

All Methods Instance Methods Concrete Methods
`java.lang.String` `absUrl​(java.lang.String key)` Get an absolute URL from a URL attribute that may be relative (such as an `<a href>` or `<img src>`).
`java.lang.String` `attr​(java.lang.String key)` Get an attribute's value by its key.
`Node` `attr​(java.lang.String key, java.lang.String value)` Set an attribute (key=value).
`Attributes` `attributes()` Get all of the element's attributes.
`java.lang.String` `baseUri()` Get the base URI that applies to this node.
`int` `childNodeSize()` Get the number of child nodes that this node holds.
`protected org.jsoup.nodes.LeafNode` `doClone​(Node parent)`
`protected void` `doSetBaseUri​(java.lang.String baseUri)` Set the baseUri for just this node (not its descendants), if this Node tracks base URIs.
`Node` `empty()` Delete all this node's children.
`protected java.util.List<Node>` `ensureChildNodes()`
`boolean` `hasAttr​(java.lang.String key)` Test if this Node has an attribute.
`protected boolean` `hasAttributes()` Check if this Node has an actual Attributes object.
`java.lang.String` `name()` Get this doctype's name (when set, or empty string)
`java.lang.String` `nodeName()` Get the node name of this node.
`java.lang.String` `publicId()` Get this doctype's Public ID (when set, or empty string)
`Node` `removeAttr​(java.lang.String key)` Remove an attribute from this node.
`void` `setPubSysKey​(java.lang.String value)`
`java.lang.String` `systemId()` Get this doctype's System ID (when set, or empty string)

### Methods inherited from class org.jsoup.nodes.Node

`addChildren, addChildren, after, after, attributesSize, before, before, childNode, childNodes, childNodesAsArray, childNodesCopy, clearAttributes, clone, equals, filter, hashCode, hasParent, hasSameValue, html, indent, nextSibling, outerHtml, outerHtml, ownerDocument, parent, parentNode, previousSibling, remove, removeChild, reparentChild, replaceChild, replaceWith, root, setBaseUri, setParentNode, setSiblingIndex, shallowClone, siblingIndex, siblingNodes, toString, traverse, unwrap, wrap`

### Methods inherited from class java.lang.Object

`finalize, getClass, notify, notifyAll, wait, wait, wait`

### Field Detail

#### PUBLIC_KEY

    public static final java.lang.String PUBLIC_KEY

See Also:
  Constant Field Values

#### SYSTEM_KEY

    public static final java.lang.String SYSTEM_KEY

See Also:
  Constant Field Values

### Constructor Detail

#### DocumentType

    public DocumentType​(java.lang.String name,
                        java.lang.String publicId,
                        java.lang.String systemId)

Create a new doctype element.

Parameters:
  `name` - the doctype's name
  `publicId` - the doctype's public ID
  `systemId` - the doctype's system ID

### Method Detail

#### setPubSysKey

    public void setPubSysKey​(java.lang.String value)

#### name

    public java.lang.String name()

Get this doctype's name (when set, or empty string)

Returns:
  doctype name

#### publicId

    public java.lang.String publicId()

Get this doctype's Public ID (when set, or empty string)

Returns:
  doctype Public ID

#### systemId

    public java.lang.String systemId()

Get this doctype's System ID (when set, or empty string)

Returns:
  doctype System ID

#### nodeName

    public java.lang.String nodeName()

Description copied from class: `Node`
Get the node name of this node. Use for debugging purposes and not logic switching (for that, use instanceof).

Specified by:
  `nodeName` in class `Node`
Returns:
  node name

#### hasAttributes

    protected final boolean hasAttributes()

Description copied from class: `Node`
Check if this Node has an actual Attributes object.

Specified by:
  `hasAttributes` in class `Node`

#### attributes

    public final Attributes attributes()

Description copied from class: `Node`
Get all of the element's attributes.

Specified by:
  `attributes` in class `Node`
Returns:
  attributes (which implements iterable, in same order as presented in original HTML).

#### attr

    public java.lang.String attr​(java.lang.String key)

Description copied from class: `Node`
Get an attribute's value by its key. Case insensitive

To get an absolute URL from an attribute that may be a relative URL, prefix the key with `abs`, which is a shortcut to the `Node.absUrl(java.lang.String)` method.

E.g.:

> `String url = a.attr("abs:href");`

Overrides:
  `attr` in class `Node`
Parameters:
  `key` - The attribute key.
Returns:
  The attribute, or empty string if not present (to avoid nulls).
See Also:
  `Node.attributes()`, `Node.hasAttr(String)`, `Node.absUrl(String)`

#### attr

    public Node attr​(java.lang.String key,
                     java.lang.String value)

Description copied from class: `Node`
Set an attribute (key=value). If the attribute already exists, it is replaced. The attribute key comparison is case insensitive. The key will be set with case sensitivity as set in the parser settings.

Overrides:
  `attr` in class `Node`
Parameters:
  `key` - The attribute key.
  `value` - The attribute value.
Returns:
  this (for chaining)

#### hasAttr

    public boolean hasAttr​(java.lang.String key)

Description copied from class: `Node`
Test if this Node has an attribute. Case insensitive.

Overrides:
  `hasAttr` in class `Node`
Parameters:
  `key` - The attribute key to check.
Returns:
  true if the attribute exists, false if not.

#### removeAttr

    public Node removeAttr​(java.lang.String key)

Description copied from class: `Node`
Remove an attribute from this node.

Overrides:
  `removeAttr` in class `Node`
Parameters:
  `key` - The attribute to remove.
Returns:
  this (for chaining)

#### absUrl

    public java.lang.String absUrl​(java.lang.String key)

Description copied from class: `Node`
Get an absolute URL from a URL attribute that may be relative (such as an `<a href>` or `<img src>`).

E.g.: `String absUrl = linkEl.absUrl("href");`

If the attribute value is already absolute (i.e. it starts with a protocol, like `http://` or `https://` etc), and it successfully parses as a URL, the attribute is returned directly. Otherwise, it is treated as a URL relative to the element's `Node.baseUri()`, and made absolute using that.

As an alternate, you can use the `Node.attr(java.lang.String)` method with the `abs:` prefix, e.g.: `String absUrl = linkEl.attr("abs:href");`

Overrides:
  `absUrl` in class `Node`
Parameters:
  `key` - The attribute key
Returns:
  An absolute URL if one could be made, or an empty string (not null) if the attribute was missing or could not be made successfully into a URL.
See Also:
  `Node.attr(java.lang.String)`, `URL(java.net.URL, String)`

#### baseUri

    public java.lang.String baseUri()

Description copied from class: `Node`
Get the base URI that applies to this node. Will return an empty string if not defined. Used to make relative links absolute.

Specified by:
  `baseUri` in class `Node`
Returns:
  base URI
See Also:
  `Node.absUrl(java.lang.String)`

#### doSetBaseUri

    protected void doSetBaseUri​(java.lang.String baseUri)

Description copied from class: `Node`
Set the baseUri for just this node (not its descendants), if this Node tracks base URIs.

Specified by:
  `doSetBaseUri` in class `Node`
Parameters:
  `baseUri` - new URI

#### childNodeSize

    public int childNodeSize()

Description copied from class: `Node`
Get the number of child nodes that this node holds.

Specified by:
  `childNodeSize` in class `Node`
Returns:
  the number of child nodes that this node holds.

#### empty

    public Node empty()

Description copied from class: `Node`
Delete all this node's children.

Specified by:
  `empty` in class `Node`
Returns:
  this node, for chaining

#### ensureChildNodes

    protected java.util.List<Node> ensureChildNodes()

Specified by:
  `ensureChildNodes` in class `Node`

#### doClone

    protected org.jsoup.nodes.LeafNode doClone​(Node parent)

Overrides:
  `doClone` in class `Node`