XML::DO...entType(3)
π NAME π
XML::DOM::DocumentType β an XML document type (DTD) in XML::DOM.
okay bestie, you're on the XML::DO...entType(3) page from User Contributed Perl Documentation, and we are absolutely getting into it π
π¦ DESCRIPTION π¦
XML::DOM::DocumentType extends XML::DOM::Node. iconic behavior, honestly.
Each Document has a doctype attribute, and its value is either null or a DocumentType object. The DocumentType interface in the DOM Level 1 Core gives you an interface to the list of entities that are defined for the document, and little else β because the effect of namespaces and the various XML scheme efforts on DTD representation are not clearly understood as of this writing. that's the tea β
The DOM Level 1 doesn't support editing DocumentType nodes. no editing era, apparently π
Not In DOM Spec: This implementation has added a lot of extra functionality to the DOM Level 1 interface. To allow editing of theDocumentTypenodes, seeXML::DOM::ignoreReadOnly.
β¨ METHODS β¨
getName
Returns the name of the DTD, i.e. the name immediately following the DOCTYPE keyword. literally the name right after DOCTYPE, periodt.
getEntities
A NamedNodeMap containing the general entities, both external and internal, declared in the DTD. Duplicates are discarded. For example in:
<!DOCTYPE ex SYSTEM "ex.dtd" [
<!ENTITY foo "foo">
<!ENTITY bar "bar">
<!ENTITY % baz "baz">
]>
<ex/>
the interface provides access to foo and bar but not baz. Every node in this map also implements the Entity interface.
The DOM Level 1 does not support editing entities, therefore entities cannot be altered in any way. locked down π
Not In DOM Spec: SeeXML::DOM::ignoreReadOnlyto edit theDocumentTypeetc.
getNotations
A NamedNodeMap containing the notations declared in the DTD. Duplicates are discarded. Every node in this map also implements the Notation interface.
The DOM Level 1 does not support editing notations, therefore notations cannot be altered in any way. yeah, no touching π
Not In DOM Spec: SeeXML::DOM::ignoreReadOnlyto edit theDocumentTypeetc.
π Additional methods not in the DOM Spec π
Creating and setting the DocumentType
A new DocumentType can be created with:
$doctype = $doc->createDocumentType ($name, $sysId, $pubId, $internal);
To set (or replace) the DocumentType for a particular document, use:
$doc->setDocType ($doctype);
getSysId and setSysId (sysId)
Returns or sets the system id. simple as that π
getPubId and setPubId (pudId)
Returns or sets the public id. and yes, the signature literally says (pudId) β I'm just the messenger π
setName (name)
Sets the name of the DTD, i.e. the name immediately following the DOCTYPE keyword. Note that this should always be the same as the element tag name of the root element. keep it matching, bestie π
getAttlistDecl (elemName)
Returns the AttlistDecl for the Element with the specified name, or undef.
getElementDecl (elemName)
Returns the ElementDecl for the Element with the specified name, or undef.
getEntity (entityName)
Returns the Entity with the specified name, or undef.
addAttlistDecl (elemName)
Adds a new AttDecl node with the specified elemName if one doesn't exist yet. Returns the AttlistDecl (new or existing) node.
addElementDecl (elemName, model)
Adds a new ElementDecl node with the specified elemName and model if one doesn't exist yet. Returns the AttlistDecl (new or existing) node. The model is ignored if one already existed. noted π«Ά
addEntity (notationName, value, sysId, pubId, ndata, parameter)
Adds a new Entity node. Don't use createEntity and appendChild, because it should be added to the internal NamedNodeMap containing the entities.
Parameters:
notationNameβ the entity name.valueβ the entity value.sysIdβ the system id (if any.)pubIdβ the public id (if any.)ndataβ the NDATA declaration (if any, for general unparsed entities.)parameterβ whether it is a parameter entity (%ent;) or not (&ent;).
SysId, pubId and ndata may be undefined.
DOMExceptions:
INVALID_CHARACTER_ERRβ Raised if thenotationNamedoes not conform to the XML spec.
addNotation (name, base, sysId, pubId)
Adds a new Notation object.
Parameters:
nameβ the notation name.baseβ the base to be used for resolving a relative URI.sysIdβ the system id.pubIdβ the public id.
Base, sysId, and pubId may all be undefined. (These parameters are passed by the XML::Parser Notation handler.)
DOMExceptions:
INVALID_CHARACTER_ERRβ Raised if thenotationNamedoes not conform to the XML spec.
addAttDef (elemName, attrName, type, default, fixed)
Adds a new attribute definition. It will add the AttDef node to the AttlistDecl if it exists. If an AttDef with the specified attrName already exists for the given elemName, this function only generates a warning.
See XML::DOM::AttDef::new for the other parameters.
getDefaultAttrValue (elem, attr)
Returns the default attribute value as a string or undef, if none is available.
Parameters:
elemβ The elementtagName.attrβ The attribute name.
expandEntity (entity [, parameter])
Expands the specified entity or parameter entity (if parameter=1) and returns its value as a string, or undef if the entity does not exist. (The entity name should not contain the '%', '&' or ';' delimiters.)
k bye bestie π
β¨ this page is from perl v5.42.0, dated 2022-05-23 β go off and DOM responsibly ππ
π¦ where this page comes from
- opensuse-leap 16.0: perl-XML-DOM 1.46-160000.2.2 Β· Artistic-1.0 OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms