NAME
HTML::Object::DOM::Implementation - HTML Object DOM Implementation
SYNOPSIS
use HTML::Object::DOM::Implementation;
my $impl = HTML::Object::DOM::Implementation->new ||
die( HTML::Object::DOM::Implementation->error, "\n" );
VERSION
v0.2.0
DESCRIPTION
The Implementation
interface represents an object providing methods which are not dependent on any particular document. Such an object is returned by the "implementation" in HTML::Object::DOM::Document property.
PROPERTIES
There are no properties
METHODS
createDocument
Provided with a namespace URI (which could be an empty string) and a qualified name for the top element, which should be html
and optionally a document type definition object and this creates and returns a document object.
Normally, this method is used to create an XML document, but we do not support XML, so this is basically an alias for "createHTMLDocument"
The namespaceURI argument is completely ignored, so do not bother and the qualified name can only be html
.
Example:
my $doc = $doc->implementation->createDocument( $namespaceURI, $qualifiedNameStr, $documentType_object );
my $doc = $doc->implementation->createDocument( '', 'html' );
my $body = $doc->createElement( 'body' );
$body->setAttribute( 'id', 'abc' );
$doc->documentElement->appendChild( $body );
say( $doc->getElementById( 'abc') ); # [object HTMLBodyElement]
See also Mozilla documentation
createDocumentType
Provided with a qualified name, which should be html
and an optional public id and system id, both of which are ignored, and this creates and returns a document type object.
Example:
my $doctype = $doc->implementation->createDocumentType( 'html', $publicId, $systemId );
my $dt = $doc->implementation->createDocumentType( 'svg:svg', '-//W3C//DTD SVG 1.1//EN', 'http://www->w3.org/Graphics/SVG/1.1/DTD/svg11.dtd' );
my $d = $doc->implementation->createDocument( 'http://www->w3.org/2000/svg', 'svg:svg', $dt );
say( $d->doctype->publicId); # -//W3C//DTD SVG 1.1//EN
See also Mozilla documentation
createHTMLDocument
Creates and returns an HTML Document.
Example:
# Assuming $title is "Demo"
my $newDoc = $doc->implementation->createHTMLDocument( $title );
Result:
<!DOCTYPE html>
<html>
<head><title>Demo</title></head>
<body></body>
</html>
See also Mozilla documentation
hasFeature
This always returns true.
Its original purpose is to return a boolean value indicating if a given feature is supported or not. However, this function has been unreliable and kept for compatibility purpose alone: except for SVG-related queries.
Example:
my $flag = $doc->implementation->hasFeature( $feature, $version );
See also Mozilla documentation
AUTHOR
Jacques Deguest <jack@deguest.jp>
SEE ALSO
COPYRIGHT & LICENSE
Copyright(c) 2022 DEGUEST Pte. Ltd.
All rights reserved
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.