HTML5-DOM

 view release on metacpan or  search on metacpan

README.pod  view on Meta::CPAN

 print $tree->document->firstChild->html; # <!DOCTYPE html>

=head3 publicId

 my $public_id = $node->publicId;
 my $node = $node->publicId($new_public_id);

Return or change public id from doctype.

 my $tree = HTML5::DOM->new->parse('
	<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
 ');
 
 # get
 print $tree->document->firstChild->publicId; # -//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN
 
 # set
 print $tree->document->firstChild->publicId('-//W3C//DTD SVG 1.1//EN');
 print $tree->document->firstChild->html; # <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">

=head3 systemId

 my $system_id = $node->systemId;
 my $node = $node->systemId($new_system_id);

Return or change public id from doctype.

 my $tree = HTML5::DOM->new->parse('
	<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
 ');
 
 # get
 print $tree->document->firstChild->systemId; # http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd
 
 # set
 print $tree->document->firstChild->systemId('http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
 print $tree->document->firstChild->html; # <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">



=head1 HTML5::DOM::Collection

CSS Parser object

=head3 new

 my $collection = HTML5::DOM::Collection->new($nodes);

lib/HTML5/DOM.pod  view on Meta::CPAN

 print $tree->document->firstChild->html; # <!DOCTYPE html>

=head3 publicId

 my $public_id = $node->publicId;
 my $node = $node->publicId($new_public_id);

Return or change public id from doctype.

 my $tree = HTML5::DOM->new->parse('
	<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
 ');
 
 # get
 print $tree->document->firstChild->publicId; # -//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN
 
 # set
 print $tree->document->firstChild->publicId('-//W3C//DTD SVG 1.1//EN');
 print $tree->document->firstChild->html; # <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">

=head3 systemId

 my $system_id = $node->systemId;
 my $node = $node->systemId($new_system_id);

Return or change public id from doctype.

 my $tree = HTML5::DOM->new->parse('
	<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">
 ');
 
 # get
 print $tree->document->firstChild->systemId; # http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd
 
 # set
 print $tree->document->firstChild->systemId('http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd');
 print $tree->document->firstChild->html; # <!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">



=head1 HTML5::DOM::Collection

CSS Parser object

=head3 new

 my $collection = HTML5::DOM::Collection->new($nodes);

t/0-api.t  view on Meta::CPAN

	ok($children->length == $child_count, "$method with fragment: check child count");

	ok($arg->childNodes->length == 0, "$method with fragment: check child count of arg");
}

#####################################
# HTML5::DOM::DocType
#####################################
my $doctype_lists = [
	{
		'in'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
		'out'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">', 
		'name'		=> 'html', 
		'systemId'	=> 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd',
		'publicId'	=> '-//W3C//DTD XHTML 1.0 Strict//EN',
	}, {
		'in'		=> '<!DOCTYPE html>',
		'out'		=> '<!DOCTYPE html>', 
		'name'		=> 'html',
		'systemId'	=> '',
		'publicId'	=> '',
	}, {
		'in'		=> '<!DOCTYPE html PUBLIC>',
		'out'		=> '<!DOCTYPE html>',
		'name'		=> 'html',

t/0-api.t  view on Meta::CPAN

		'name'		=> 'html',
		'publicId'	=> '-//W3C//DTD HTML 4.01//EN',
		'systemId'	=> ''
	}, {
		'in'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
		'out'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
		'name'		=> 'html',
		'publicId'	=> '-//W3C//DTD HTML 4.01//EN',
		'systemId'	=> 'http://www.w3.org/TR/html4/strict.dtd'
	}, {
		'in'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
		'out'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
		'name'		=> 'html',
		'publicId'	=> '-//W3C//DTD XHTML 1.0 Strict//EN',
		'systemId'	=> 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd'
	}, {
		'in'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
		'out'		=> '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
		'name'		=> 'html',
		'publicId'	=> '-//W3C//DTD XHTML 1.1//EN',
		'systemId'	=> 'http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd'
	}, {
		'in'		=> '<!DOCTYPE html SYSTEM "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
		'out'		=> '<!DOCTYPE html SYSTEM "-//W3C//DTD XHTML 1.1//EN">',
		'name'		=> 'html',
		'publicId'	=> '',
		'systemId'	=> '-//W3C//DTD XHTML 1.1//EN',
	}, {
		'in'		=> '<!DOCTYPE OlOlLo>',
		'out'		=> '<!DOCTYPE olollo>',
		'name'		=> 'olollo',
		'publicId'	=> '',
		'systemId'	=> '',
	}, {
		'in'		=> '<!DOCTYPE html PUBLIC "" "xxx">',
		'out'		=> '<!DOCTYPE html SYSTEM "xxx">',
		'name'		=> 'html',
		'publicId'	=> '',
		'systemId'	=> 'xxx',
	}, {
		'in'		=> '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
		'out'		=> '<!DOCTYPE svg:svg PUBLIC "-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN" "http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd">',
		'name'		=> 'svg:svg',
		'publicId'	=> '-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN',
		'systemId'	=> 'http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd'
	}
];

# basic doctype tests
for my $dt (@$doctype_lists) {
	my $tree = HTML5::DOM->new->parse($dt->{in});
	
	if ($dt == $doctype_lists->[0]) {
		isa_ok($tree->document->firstChild, 'HTML5::DOM::DocType', 'check doctype isa');

t/0-api.t  view on Meta::CPAN

}

# test change value
my $doctype_test_change = [
	{
		method		=> 'name', 
		value		=> 'svg'
	}, 
	{
		method		=> 'publicId', 
		value		=> '-//W3C//DTD XHTML 1.1 plus MathML 2.0 plus SVG 1.1//EN'
	}, 
	{
		method		=> 'systemId', 
		value		=> 'http://www.w3.org/2002/04/xhtml-math-svg/xhtml-math-svg.dtd'
	}
];
for my $test (@$doctype_test_change) {
	my @doctypes = (
		'<!DOCTYPE>', 
		'<!DOCTYPE html>', 

third_party/modest/source/myhtml/token.c  view on Meta::CPAN

{
    return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD HTML 4.01//EN") &&
    (return_doctype->attr_system == NULL || mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/html4/strict.dtd"));
}

bool myhtml_token_doctype_check_xhtml_1_0(myhtml_tree_doctype_t* return_doctype)
{
    if(return_doctype->attr_system == NULL)
        return true;
    
    return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD XHTML 1.0 Strict//EN") &&
    mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd");
}

bool myhtml_token_doctype_check_xhtml_1_1(myhtml_tree_doctype_t* return_doctype)
{
    if(return_doctype->attr_system == NULL)
        return true;
    
    return mycore_strcmp(return_doctype->attr_public, "-//W3C//DTD XHTML 1.1//EN") &&
    mycore_strcmp(return_doctype->attr_system, "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd");
}

bool myhtml_token_release_and_check_doctype_attributes(myhtml_token_t* token, myhtml_token_node_t* target, myhtml_tree_doctype_t* return_doctype)
{
    if(return_doctype == NULL)
        return false;
    
    myhtml_token_strict_doctype_by_token(token, target, return_doctype);
    



( run in 1.316 second using v1.01-cache-2.11-cpan-49f99fa48dc )