18 |
@@Module: |
@@Module: |
19 |
@@@QName: MDOM|DOMLS |
@@@QName: MDOM|DOMLS |
20 |
@@@WithFor: ManakaiDOM|ManakaiDOMLatest |
@@@WithFor: ManakaiDOM|ManakaiDOMLatest |
21 |
|
@@Module: |
22 |
|
@@@QName: MDOM|XDoctype |
23 |
|
@@@WithFor: ManakaiDOM|ManakaiDOMLatest |
24 |
|
|
25 |
Namespace: |
Namespace: |
26 |
|
@d: |
27 |
|
http://suika.fam.cx/~wakaba/archive/2004/dom/xdt# |
28 |
@dis: |
@dis: |
29 |
http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis-- |
http://suika.fam.cx/~wakaba/archive/2004/8/18/lang#dis-- |
30 |
@DOMCore: |
@DOMCore: |
116 |
@AliasFor: t|Document |
@AliasFor: t|Document |
117 |
@For: ManakaiDOM|DOM |
@For: ManakaiDOM|DOM |
118 |
|
|
119 |
|
ResourceDef: |
120 |
|
@QName: DocumentXDoctype |
121 |
|
@AliasFor: d|DocumentXDoctype |
122 |
|
@For: ManakaiDOM|DOM |
123 |
|
|
124 |
ElementTypeBinding: |
ElementTypeBinding: |
125 |
@Name: ClsDef |
@Name: ClsDef |
126 |
@ElementType: |
@ElementType: |
251 |
|
|
252 |
$self->{char} = []; |
$self->{char} = []; |
253 |
$self->{token} = []; |
$self->{token} = []; |
254 |
$self->{source} = $sourceText; |
$self->{entity} = [{ |
255 |
|
reptxt => \$sourceText, |
256 |
|
line => 1, |
257 |
|
column => 1, |
258 |
|
pos => 0, |
259 |
|
}]; |
260 |
|
$self->{entity_char} = []; |
261 |
|
$self->{entity_token} = []; |
262 |
$self->{xml_version} = '1.0'; |
$self->{xml_version} = '1.0'; |
263 |
$self->{standalone} = false; |
$self->{standalone} = false; |
264 |
|
$self->{general_entity} = {}; |
265 |
|
$self->{param_entity} = {}; |
266 |
|
$self->{has_error} = false; |
267 |
## Well-formedness constraint Entity Declared takes effect? |
## Well-formedness constraint Entity Declared takes effect? |
|
$self->{line} = 1; |
|
|
$self->{column} = 1; |
|
268 |
|
|
269 |
__DEEP{ |
__DEEP{ |
270 |
$r = $self->_parse_DocumentEntity |
$r = $self->_parse_DocumentEntity |
281 |
@@@Type: idl|long||ManakaiDOM|all |
@@@Type: idl|long||ManakaiDOM|all |
282 |
@@@enDesc: |
@@@enDesc: |
283 |
The code position number of the next character, if any, |
The code position number of the next character, if any, |
284 |
or <CODE::-2>. |
or <CODE::-1>. |
285 |
@@@PerlDef: |
@@@PerlDef: |
286 |
if (@{$self->{char}}) { |
if (@{$self->{char}}) { |
287 |
$r = shift @{$self->{char}}; |
$r = shift @{$self->{char}}; |
288 |
} else { |
} else { |
289 |
my $char = substr ($self->{source}, pos ($self->{source}), 1); |
GETCHAR: { |
290 |
pos ($self->{source})++; |
my $char = substr (${$self->{entity}->[-1]->{reptxt}}, |
291 |
|
$self->{entity}->[-1]->{pos}, 1); |
292 |
if (length $char) { |
$self->{entity}->[-1]->{pos}++; |
293 |
$r = ord $char; |
|
294 |
if ($r == 0x000A) { |
if (length $char) { |
295 |
$self->{line}++; |
$r = ord $char; |
296 |
$self->{column} = 1; |
if ($r == 0x000A) { |
297 |
} elsif ($r == 0x000D) { |
$self->{entity}->[-1]->{line}++; |
298 |
my $next_char = substr ($self->{source}, |
$self->{entity}->[-1]->{column} = 1; |
299 |
pos ($self->{source}), 1); |
} elsif ($r == 0x000D) { |
300 |
if ($next_char eq "\x0A") { |
my $next_char = substr (${$self->{entity}->[-1]->{reptxt}}, |
301 |
pos ($self->{source})++; |
$self->{entity}->[-1]->{pos}, 1); |
302 |
$self->{column} = 1; |
if ($next_char eq "\x0A") { |
303 |
} elsif ($next_char eq "\x85") { |
$self->{entity}->[-1]->{pos}++; |
304 |
if ($self->{xml_version} eq '1.1') { |
$self->{entity}->[-1]->{column} = 1; |
305 |
pos ($self->{source})++; |
} elsif ($next_char eq "\x85") { |
306 |
$self->{column} = 1; |
if ($self->{xml_version} eq '1.1') { |
307 |
|
$self->{entity}->[-1]->{pos}++; |
308 |
|
$self->{entity}->[-1]->{column} = 1; |
309 |
|
} else { |
310 |
|
$self->{entity}->[-1]->{column} = 0; |
311 |
|
} |
312 |
} else { |
} else { |
313 |
$self->{column} = 0; |
$self->{entity}->[-1]->{column} = 1; |
314 |
|
} |
315 |
|
$r = 0x000A; |
316 |
|
$self->{entity}->[-1]->{line}++; |
317 |
|
} elsif ( |
318 |
|
not ((0x0020 <= $r and $r <= 0x007E) or |
319 |
|
(0x00A0 <= $r and $r <= 0xD7FF) or |
320 |
|
(0xE000 <= $r and $r <= 0xFFFD) or |
321 |
|
(0x10000 <= $r and $r <= 0x10FFFF)) and |
322 |
|
$r != 0x0009 and $r != 0x0085 and |
323 |
|
not ($self->{xml_version} eq '1.0' and |
324 |
|
(0x007F <= $r and $r <= 0x009F)) |
325 |
|
) { |
326 |
|
my $location = { |
327 |
|
utf32_offset => $self->{entity}->[-1]->{pos}, |
328 |
|
line_number => $self->{entity}->[-1]->{line}, |
329 |
|
column_number => $self->{entity}->[-1]->{column}, |
330 |
|
}; |
331 |
|
my $continue = __DOMCore:ERROR{xp|wf-legal-literal-character:: |
332 |
|
DOMCore|location => {$location}, |
333 |
|
xp|character-number => {$r}, |
334 |
|
}__; |
335 |
|
unless ($continue) { |
336 |
|
__EXCEPTION{DOMLS|PARSE_ERR}__; |
337 |
} |
} |
338 |
|
$self->{has_error} = true; |
339 |
|
$self->{entity}->[-1]->{column}++; |
340 |
|
} elsif ($r == 0x0085 or $r == 0x2028) { |
341 |
|
$r = 0x000A if $self->{xml_version} eq '1.1'; |
342 |
|
$self->{entity}->[-1]->{line}++; |
343 |
|
$self->{entity}->[-1]->{column} = 1; |
344 |
} else { |
} else { |
345 |
$self->{column} = 1; |
$self->{entity}->[-1]->{column}++; |
346 |
} |
} |
347 |
$r = 0x000A; |
# } elsif (@{$self->{entity}} > 1) { |
348 |
$self->{line}++; |
# pop @{$self->{entity}}; |
349 |
} elsif ( |
# redo GETCHAR; |
350 |
not ((0x0020 <= $r and $r <= 0x007E) or |
# ## ISSUE: How cope with delimiter scanning & |
351 |
(0x00A0 <= $r and $r <= 0xD7FF) or |
# ## self-containedness constraints?? |
|
(0xE000 <= $r and $r <= 0xFFFD) or |
|
|
(0x10000 <= $r and $r <= 0x10FFFF)) and |
|
|
$r != 0x0009 and $r != 0x0085 and |
|
|
not ($self->{xml_version} eq '1.0' and |
|
|
(0x007F <= $r and $r <= 0x009F)) |
|
|
) { |
|
|
my $location = { |
|
|
utf32_offset => pos ($self->{source}), |
|
|
line_number => $self->{line}, |
|
|
column_number => $self->{column}, |
|
|
}; |
|
|
my $continue = __DOMCore:ERROR{xp|wf-legal-literal-character:: |
|
|
DOMCore|location => {$location}, |
|
|
xp|character-number => {$r}, |
|
|
}__; |
|
|
unless ($continue) { |
|
|
__EXCEPTION{DOMLS|PARSE_ERR}__; |
|
|
} |
|
|
$self->{has_error} = true; |
|
|
$self->{column}++; |
|
|
} elsif ($r == 0x0085 or $r == 0x2028) { |
|
|
$r = 0x000A if $self->{xml_version} eq '1.1'; |
|
|
$self->{line}++; |
|
|
$self->{column} = 1; |
|
352 |
} else { |
} else { |
353 |
$self->{column}++; |
$r = -1; |
354 |
} |
} |
355 |
} else { |
} # GETCHAR |
|
$r = -1; |
|
|
} |
|
356 |
} |
} |
357 |
|
|
358 |
@Method: |
@Method: |
840 |
|
|
841 |
lang:Perl { |
lang:Perl { |
842 |
$parent-><M::Node.appendChild> ($pi); |
$parent-><M::Node.appendChild> ($pi); |
|
## TODO: PIs in document type declaration subsets |
|
843 |
} |
} |
844 |
|
|
845 |
// ~ (PIC) { } |
// ~ (PIC) { } |
846 |
} // _ProcessingInstruction_ |
} // _ProcessingInstruction_ |
847 |
|
|
848 |
rule _ProcessingInstructionDTD ($doc) { |
/* |
849 |
|
Processing instruction in DTD |
850 |
|
*/ |
851 |
|
rule _ProcessingInstructionDTD ($doc, $doctype) { |
852 |
?lexmode 'PIName'; |
?lexmode 'PIName'; |
853 |
|
|
854 |
|
my $pi; |
855 |
|
|
856 |
~ (Name) { |
~ (Name) { |
857 |
|
lang:Perl ($name => $token.value) : has-error { |
858 |
|
if (lc $name eq 'xml') { |
859 |
|
my $location; |
860 |
|
__CODE{xp|get-location-from-token:: |
861 |
|
$token => {$token}, |
862 |
|
$result => {$location}, |
863 |
|
}__; |
864 |
|
my $continue = __DOMCore:ERROR{xp|wf-pi-target-is-xml:: |
865 |
|
xp|name => {$name}, |
866 |
|
DOMCore|location => {$location}, |
867 |
|
xp|parent => {$doctype}, |
868 |
|
}__; |
869 |
|
unless ($continue) { |
870 |
|
__EXCEPTION{DOMLS|PARSE_ERR:: |
871 |
|
}__; |
872 |
|
} |
873 |
|
$self->{has_error} = true; |
874 |
|
} |
875 |
|
## TODO: Namespace well-formedness |
876 |
|
$pi = $doc-><M::Document.createProcessingInstruction> |
877 |
|
($name); |
878 |
|
} |
879 |
} |
} |
880 |
|
|
881 |
~ (S) { |
~ (S) { |
882 |
?lexmode 'PIData'; |
?lexmode 'PIData'; |
883 |
|
|
884 |
|
my $tdata; |
885 |
|
|
886 |
~? (DATA) { |
~? (DATA) { |
887 |
|
lang:Perl ($data => $token.value) { |
888 |
|
$tdata = $data; |
889 |
|
} |
890 |
|
} else { |
891 |
|
lang:Perl { |
892 |
|
$tdata = ''; |
893 |
|
} |
894 |
} |
} |
895 |
|
|
896 |
|
lang:Perl { |
897 |
|
$pi-><AS::Node.nodeValue> ($tdata); |
898 |
|
} |
899 |
|
} |
900 |
|
|
901 |
|
lang:Perl { |
902 |
|
$doctype-><M::Node.appendChild> ($pi); |
903 |
} |
} |
904 |
|
|
905 |
~ (PIC) { |
~ (PIC) { |
917 |
content := (CharData / element / Reference / CDSect / |
content := (CharData / element / Reference / CDSect / |
918 |
PI / Comment) ;; [43] |
PI / Comment) ;; [43] |
919 |
*/ |
*/ |
920 |
rule Element_ ($doc, $parent) : standalone { |
rule Element_ ($doc, $parent, $ns) : standalone { |
921 |
?lexmode 'ElementContent'; |
?lexmode 'ElementContent'; |
922 |
|
|
923 |
my $node; // Current "parent" node |
my $node; // Current "parent" node |
924 |
my $nodes; // Node stack (w/o $current_node) |
my $nodes; // Node stack (w/o $current_node) |
925 |
my $type; // Current "parent" element type QName |
my $type; // Current "parent" element type QName |
926 |
my $types; // Element type stack (w/o $current_type) |
my $types; // Element type stack (w/o $current_type) |
927 |
my $ns; // Current in-scope namespace bindings |
//my $ns; // Current in-scope namespace bindings |
928 |
my $nses; // Namespace binding stack (w/o $current_ns) |
my $nses; // Namespace binding stack (w/o $current_ns) |
929 |
|
|
930 |
lang:Perl { |
lang:Perl { |
932 |
$nodes = []; |
$nodes = []; |
933 |
$type = ''; |
$type = ''; |
934 |
$types = []; |
$types = []; |
935 |
$ns = { |
$ns ||= { |
936 |
xml => <Q::xml:>, |
xml => <Q::xml:>, |
937 |
xmlns => <Q::xmlns:>, |
xmlns => <Q::xmlns:>, |
938 |
}; |
}; |
1069 |
$node = $el; |
$node = $el; |
1070 |
} |
} |
1071 |
?lexmode ElementContent; |
?lexmode ElementContent; |
1072 |
} (MTAGC) { |
} (NESTC) { |
1073 |
|
my $is_docel; |
1074 |
lang:Perl { |
lang:Perl { |
1075 |
$ns = pop @{$nses}; |
$ns = pop @{$nses}; |
1076 |
$type = pop @{$types}; |
$type = pop @{$types}; |
1077 |
|
$is_docel = (@{$types} == 0); |
1078 |
|
} |
1079 |
|
|
1080 |
|
if-true ($is_docel) { |
1081 |
|
return; |
1082 |
|
} |
1083 |
|
|
1084 |
|
~ (TAGC) { |
1085 |
|
?lexmode ElementContent; |
1086 |
|
} else { |
1087 |
|
?lexmode ElementContent; |
1088 |
} |
} |
|
?lexmode ElementContent; |
|
1089 |
} else { |
} else { |
1090 |
?lexmode ElementContent; |
?lexmode ElementContent; |
1091 |
} |
} |
1183 |
?lexmode ElementContent; |
?lexmode ElementContent; |
1184 |
} |
} |
1185 |
} (ERO) { |
} (ERO) { |
1186 |
&_GeneralEntityReference_ |
&_GeneralEntityReferenceEC |
1187 |
($doc => $doc, $parent => $node); |
($doc => $doc, $parent => $node, $ns => $ns); |
|
|
|
|
~ (REFC) { |
|
|
?lexmode 'ElementContent'; |
|
|
} else { |
|
|
?lexmode ElementContent; |
|
|
} |
|
1188 |
} (CDO) { |
} (CDO) { |
1189 |
&_CommentDeclaration_ ($doc => $doc, $parent => $node); |
&_CommentDeclaration_ ($doc => $doc, $parent => $node); |
1190 |
|
|
1564 |
// ~ (REFC) { } |
// ~ (REFC) { } |
1565 |
} // _HexadecimalCharacterReferenceV_ |
} // _HexadecimalCharacterReferenceV_ |
1566 |
|
|
1567 |
rule _GeneralEntityReference_ ($doc, $parent) { |
/* |
1568 |
// TODO: Expansion |
General entity reference in element's content |
1569 |
|
*/ |
1570 |
|
rule _GeneralEntityReferenceEC ($doc, $parent, $ns) |
1571 |
|
: recursive |
1572 |
|
{ |
1573 |
?lexmode 'EntityReference'; |
?lexmode 'EntityReference'; |
1574 |
|
|
1575 |
~ (Name) { |
~ (Name) { |
1576 |
|
my $er; |
1577 |
lang:Perl ($name => $token.value) { |
lang:Perl ($name => $token.value) { |
1578 |
## TODO: Namespace well-formedness |
## TODO: Namespace well-formedness |
1579 |
## TODO: Entity declared constraints |
## TODO: Entity declared constraints |
1580 |
my $er = $doc-><M::Document.createEntityReference> |
$er = $doc-><M::Document.createEntityReference> |
1581 |
($name); |
($name); |
1582 |
$parent-><M::Node.appendChild> ($er); |
$parent-><M::Node.appendChild> ($er); |
1583 |
|
push @{$self->{entity}}, <Code::getCopyOfEntityState:: |
1584 |
|
$entity_type = 'general_entity', |
1585 |
|
$entity_name = $name>; |
1586 |
|
push @{$self->{entity_token}}, $self->{token}; |
1587 |
|
$self->{token} = []; |
1588 |
|
push @{$self->{entity_char}}, $self->{char}; |
1589 |
|
$self->{char} = []; |
1590 |
|
} |
1591 |
|
|
1592 |
|
?lexmode ElementContent; |
1593 |
|
~* (CharData) { |
1594 |
|
lang:Perl ($data => $token.value) { |
1595 |
|
$er-><M::Node.appendChild> |
1596 |
|
($doc-><M::Document.createTextNode> ($data)); |
1597 |
|
} |
1598 |
|
} (STAGO) { |
1599 |
|
&Element_ ($doc => $doc, $parent => $er, $ns => $ns) |
1600 |
|
: unshift-current-token; |
1601 |
|
~ (TAGC) { |
1602 |
|
?lexmode ElementContent; |
1603 |
|
} else { |
1604 |
|
?lexmode ElementContent; |
1605 |
|
} |
1606 |
|
} (HCRO) { |
1607 |
|
&_HexadecimalCharacterReference_ |
1608 |
|
($doc => $doc, $parent => $er); |
1609 |
|
|
1610 |
|
~ (REFC) { |
1611 |
|
?lexmode 'ElementContent'; |
1612 |
|
} else { |
1613 |
|
?lexmode ElementContent; |
1614 |
|
} |
1615 |
|
} (CRO) { |
1616 |
|
&_NumericCharacterReference_ |
1617 |
|
($doc => $doc, $parent => $er); |
1618 |
|
|
1619 |
|
~ (REFC) { |
1620 |
|
?lexmode 'ElementContent'; |
1621 |
|
} else { |
1622 |
|
?lexmode ElementContent; |
1623 |
|
} |
1624 |
|
} (ERO) { |
1625 |
|
&_GeneralEntityReferenceEC |
1626 |
|
($doc => $doc, $parent => $er, $ns => $ns); |
1627 |
|
} (CDO) { |
1628 |
|
&_CommentDeclaration_ ($doc => $doc, $parent => $er); |
1629 |
|
|
1630 |
|
~ (MDC) { |
1631 |
|
?lexmode ElementContent; |
1632 |
|
} else { |
1633 |
|
?lexmode ElementContent; |
1634 |
|
} |
1635 |
|
} (CDSO) { |
1636 |
|
&_CDATASection_ ($doc => $doc, $parent => $er); |
1637 |
|
|
1638 |
|
~ (MSE) { |
1639 |
|
?lexmode 'ElementContent'; |
1640 |
|
} else { |
1641 |
|
?lexmode ElementContent; |
1642 |
|
} |
1643 |
|
} (PIO) { |
1644 |
|
&_ProcessingInstruction_ ($doc => $doc, $parent => $er); |
1645 |
|
|
1646 |
|
~ (PIC) { |
1647 |
|
?lexmode 'ElementContent'; |
1648 |
|
} else { |
1649 |
|
?lexmode ElementContent; |
1650 |
|
} |
1651 |
} |
} |
1652 |
|
|
1653 |
|
~ (#EOF) { } |
1654 |
|
lang:Perl { |
1655 |
|
$self->{token} = pop @{$self->{entity_token}}; |
1656 |
|
$self->{char} = pop @{$self->{entity_char}}; |
1657 |
|
pop @{$self->{entity}}; |
1658 |
|
} |
1659 |
|
|
1660 |
|
?lexmode EntityReference; |
1661 |
|
?requires-next-token; |
1662 |
} |
} |
1663 |
|
|
1664 |
// ~ (REFC) { } |
~ (REFC) { |
1665 |
} // _GeneralEntityReference_ |
?lexmode ElementContent; |
1666 |
|
} else { |
1667 |
|
?lexmode ElementContent; |
1668 |
|
} |
1669 |
|
} // _GeneralEntityReferenceEC |
1670 |
|
|
1671 |
rule _GeneralEntityReferenceV_ ($doc, $vals) { |
rule _GeneralEntityReferenceV_ ($doc, $vals) { |
1672 |
// TODO: Expansion |
// TODO: Expansion |
1684 |
|
|
1685 |
// ~ (REFC) { } |
// ~ (REFC) { } |
1686 |
} // _GeneralEntityReferenceV_ |
} // _GeneralEntityReferenceV_ |
1687 |
|
|
1688 |
|
/* |
1689 |
|
General entity reference in literal entity value |
1690 |
|
*/ |
1691 |
|
rule _GeneralEntityReferenceEV_ ($doc, $vals) { |
1692 |
|
?lexmode 'EntityReference'; |
1693 |
|
|
1694 |
|
~ (Name) { |
1695 |
|
lang:Perl ($name => $token.value) { |
1696 |
|
## TODO: Namespace well-formedness |
1697 |
|
## TODO: Entity declared constraints |
1698 |
|
push @$vals, $name; |
1699 |
|
} |
1700 |
|
} |
1701 |
|
|
1702 |
|
// ~ (REFC) { } |
1703 |
|
} // _GeneralEntityReferenceEV_ |
1704 |
|
|
1705 |
/* |
/* |
1706 |
Document Type Declaration |
Document Type Declaration |
1712 |
|
|
1713 |
~ (S) { } |
~ (S) { } |
1714 |
|
|
1715 |
|
my $node; |
1716 |
// Document type name |
// Document type name |
1717 |
|
my $name; |
1718 |
~ (Name) { |
~ (Name) { |
1719 |
|
lang:Perl ($v => $token.value) { |
1720 |
|
$name = $v; |
1721 |
|
} |
1722 |
|
} |
1723 |
|
lang:Perl { |
1724 |
|
$node = $doc-><M::DocumentXDoctype.createDocumentTypeDefinition> ($name); |
1725 |
|
$doc-><M::Node.appendChild> ($node); |
1726 |
} |
} |
1727 |
|
|
1728 |
~? (S) { |
~? (S) { |
1746 |
} |
} |
1747 |
|
|
1748 |
~? (DSO) { |
~? (DSO) { |
1749 |
&InternalSubset ($doc => $doc); |
&InternalSubset ($doc => $doc, $doctype => $node); |
1750 |
|
|
1751 |
~ (DSC) { |
~ (DSC) { |
1752 |
?lexmode MarkupDeclaration; |
?lexmode MarkupDeclaration; |
1822 |
|
|
1823 |
intSubset := *(markupdecl / DeclSep) ;; [28b] |
intSubset := *(markupdecl / DeclSep) ;; [28b] |
1824 |
*/ |
*/ |
1825 |
rule InternalSubset ($doc) { |
rule InternalSubset ($doc, $doctype) { |
1826 |
?lexmode DTD; |
?lexmode DTD; |
1827 |
|
|
1828 |
~* (MDO) { |
~* (MDO) { |
1842 |
} (CDO) { |
} (CDO) { |
1843 |
&_CommentDeclarationDTD ($doc => $doc); |
&_CommentDeclarationDTD ($doc => $doc); |
1844 |
} (PIO) { |
} (PIO) { |
1845 |
&_ProcessingInstructionDTD ($doc => $doc); |
&_ProcessingInstructionDTD ($doc => $doc, $doctype => $doctype); |
1846 |
} (PERO) { |
} (PERO) { |
1847 |
?lexmode EntityReference; |
?lexmode EntityReference; |
1848 |
|
|
2153 |
|
|
2154 |
~ (S) { } |
~ (S) { } |
2155 |
|
|
2156 |
|
my $decl; |
2157 |
|
lang:Perl { $decl = {}; } |
2158 |
|
|
2159 |
~? (PERO) { |
~? (PERO) { |
2160 |
~ (S) { } |
~ (S) { } |
2161 |
|
lang:Perl { |
2162 |
|
$decl->{is_param_entity} = true; |
2163 |
|
} |
2164 |
} |
} |
2165 |
|
|
2166 |
~ (Name) { |
~ (Name) { |
2167 |
|
lang:Perl ($v => $token.value) { |
2168 |
|
$decl->{name} = $v; |
2169 |
|
} |
2170 |
} |
} |
2171 |
|
|
2172 |
~ (S) { } |
~ (S) { } |
2173 |
|
|
2174 |
~ (LIT) { |
~ (LIT) { |
2175 |
&_EntityValue ($doc => $doc); |
&_EntityValue ($doc => $doc, $decl => $decl); |
2176 |
} (LITA) { |
} (LITA) { |
2177 |
&_EntityValueA ($doc => $doc); |
&_EntityValueA ($doc => $doc, $decl => $decl); |
2178 |
} (Name == 'PUBLIC') { |
} (Name == 'PUBLIC') { |
2179 |
~ (S) { } |
~ (S) { } |
2180 |
|
|
2181 |
&PubidLiteral ($doc => $doc); |
&PubidLiteral ($doc => $doc, $decl => $decl); |
2182 |
|
|
2183 |
~ (S) { } |
~ (S) { } |
2184 |
|
|
2185 |
&SystemLiteral ($doc => $doc); |
&SystemLiteral ($doc => $doc, $decl => $decl); |
2186 |
} (Name == 'SYSTEM') { |
} (Name == 'SYSTEM') { |
2187 |
~ (S) { } |
~ (S) { } |
2188 |
|
|
2189 |
&SystemLiteral ($doc => $doc); |
&SystemLiteral ($doc => $doc, $decl => $decl); |
2190 |
} |
} |
2191 |
|
|
2192 |
~? (S) { |
~? (S) { |
2196 |
~ (S) { } |
~ (S) { } |
2197 |
|
|
2198 |
~ (Name) { |
~ (Name) { |
2199 |
|
lang:Perl ($v => $token.value) { |
2200 |
|
$decl->{notation} = $v; |
2201 |
|
} |
2202 |
} |
} |
2203 |
|
|
2204 |
~? (S) { } |
~? (S) { } |
2205 |
} |
} |
2206 |
} |
} |
2207 |
|
|
2208 |
|
lang:Perl { |
2209 |
|
if ($self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'} |
2210 |
|
->{$decl->{name}}) { |
2211 |
|
## TODO: error |
2212 |
|
} else { |
2213 |
|
$self->{$decl->{is_param_entity} ? 'param_entity' : 'general_entity'} |
2214 |
|
->{$decl->{name}} = $decl; |
2215 |
|
} |
2216 |
|
} |
2217 |
|
|
2218 |
~ (MDC) { |
~ (MDC) { |
2219 |
?lexmode DTD; |
?lexmode DTD; |
2220 |
} else { |
} else { |
2267 |
} |
} |
2268 |
} // _NotationDeclaration |
} // _NotationDeclaration |
2269 |
|
|
2270 |
rule _EntityValue ($doc) { |
rule _EntityValue ($doc, $decl) { |
2271 |
?lexmode EntityValue; |
?lexmode EntityValue; |
2272 |
|
|
2273 |
my $vals; |
my $vals; |
2274 |
|
my $reptxt; |
2275 |
lang:Perl { |
lang:Perl { |
2276 |
$vals = []; |
$vals = []; |
2277 |
|
$reptxt = ''; |
2278 |
} |
} |
2279 |
|
|
2280 |
~* (STRING) { |
~* (STRING) { |
2281 |
|
lang:Perl ($v => $token.value) { |
2282 |
|
$reptxt .= $v; |
2283 |
|
} |
2284 |
} (PERO) { |
} (PERO) { |
2285 |
?lexmode EntityDeclaration; |
?lexmode EntityDeclaration; |
2286 |
|
|
2287 |
|
// TODO: Expand or wferror if internal subset |
2288 |
|
|
2289 |
~ (Name) { |
~ (Name) { |
2290 |
|
|
2299 |
&_HexadecimalCharacterReferenceV_ |
&_HexadecimalCharacterReferenceV_ |
2300 |
($doc => $doc, $vals => $vals); |
($doc => $doc, $vals => $vals); |
2301 |
|
|
2302 |
|
lang:Perl { |
2303 |
|
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2304 |
|
$vals = []; |
2305 |
|
} |
2306 |
|
|
2307 |
~ (REFC) { |
~ (REFC) { |
2308 |
?lexmode EntityValue; |
?lexmode EntityValue; |
2309 |
} else { |
} else { |
2312 |
} (CRO) { |
} (CRO) { |
2313 |
&_NumericCharacterReferenceV_ |
&_NumericCharacterReferenceV_ |
2314 |
($doc => $doc, $vals => $vals); |
($doc => $doc, $vals => $vals); |
2315 |
|
|
2316 |
|
lang:Perl { |
2317 |
|
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2318 |
|
$vals = []; |
2319 |
|
} |
2320 |
|
|
2321 |
~ (REFC) { |
~ (REFC) { |
2322 |
?lexmode EntityValue; |
?lexmode EntityValue; |
2324 |
?lexmode EntityValue; |
?lexmode EntityValue; |
2325 |
} |
} |
2326 |
} (ERO) { |
} (ERO) { |
2327 |
&_GeneralEntityReferenceV_ |
&_GeneralEntityReferenceEV_ |
2328 |
($doc => $doc, $vals => $vals); |
($doc => $doc, $vals => $vals); |
2329 |
|
|
2330 |
|
lang:Perl { |
2331 |
|
$reptxt .= '&' . $vals->[0] . ';'; |
2332 |
|
$vals = []; |
2333 |
|
} |
2334 |
|
|
2335 |
~ (REFC) { |
~ (REFC) { |
2336 |
?lexmode EntityValue; |
?lexmode EntityValue; |
2337 |
} else { |
} else { |
2346 |
} else { |
} else { |
2347 |
?lexmode MarkupDeclaration; |
?lexmode MarkupDeclaration; |
2348 |
} |
} |
2349 |
|
|
2350 |
|
lang:Perl { |
2351 |
|
$decl->{reptxt} = \$reptxt; |
2352 |
|
} |
2353 |
} // _EntityValue |
} // _EntityValue |
2354 |
|
|
2355 |
rule _EntityValueA ($doc) { |
rule _EntityValueA ($doc, $decl) { |
2356 |
?lexmode EntityValueA; |
?lexmode EntityValueA; |
2357 |
|
|
2358 |
my $vals; |
my $vals; |
2359 |
|
my $reptxt; |
2360 |
lang:Perl { |
lang:Perl { |
2361 |
$vals = []; |
$vals = []; |
2362 |
|
$reptxt = ''; |
2363 |
} |
} |
2364 |
|
|
2365 |
~* (STRING) { |
~* (STRING) { |
2366 |
|
lang:Perl ($v => $token.value) { |
2367 |
|
$reptxt .= $v; |
2368 |
|
} |
2369 |
} (PERO) { |
} (PERO) { |
2370 |
?lexmode EntityDeclaration; |
?lexmode EntityDeclaration; |
2371 |
|
|
2372 |
|
// TODO: implement this |
2373 |
~ (Name) { |
~ (Name) { |
2374 |
|
|
2375 |
} |
} |
2383 |
&_HexadecimalCharacterReferenceV_ |
&_HexadecimalCharacterReferenceV_ |
2384 |
($doc => $doc, $vals => $vals); |
($doc => $doc, $vals => $vals); |
2385 |
|
|
2386 |
|
lang:Perl { |
2387 |
|
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2388 |
|
$vals = []; |
2389 |
|
} |
2390 |
|
|
2391 |
|
|
2392 |
~ (REFC) { |
~ (REFC) { |
2393 |
?lexmode EntityValueA; |
?lexmode EntityValueA; |
2394 |
} else { |
} else { |
2398 |
&_NumericCharacterReferenceV_ |
&_NumericCharacterReferenceV_ |
2399 |
($doc => $doc, $vals => $vals); |
($doc => $doc, $vals => $vals); |
2400 |
|
|
2401 |
|
lang:Perl { |
2402 |
|
$reptxt .= $vals->[0]-><AG::Node.textContent>; |
2403 |
|
$vals = []; |
2404 |
|
} |
2405 |
|
|
2406 |
~ (REFC) { |
~ (REFC) { |
2407 |
?lexmode EntityValueA; |
?lexmode EntityValueA; |
2408 |
} else { |
} else { |
2409 |
?lexmode EntityValueA; |
?lexmode EntityValueA; |
2410 |
} |
} |
2411 |
} (ERO) { |
} (ERO) { |
2412 |
&_GeneralEntityReferenceV_ |
&_GeneralEntityReferenceEV_ |
2413 |
($doc => $doc, $vals => $vals); |
($doc => $doc, $vals => $vals); |
2414 |
|
|
2415 |
|
lang:Perl { |
2416 |
|
$reptxt .= '&' . $vals->[0] . ';'; |
2417 |
|
$vals = []; |
2418 |
|
} |
2419 |
|
|
2420 |
~ (REFC) { |
~ (REFC) { |
2421 |
?lexmode EntityValueA; |
?lexmode EntityValueA; |
2422 |
} else { |
} else { |
2429 |
} else { |
} else { |
2430 |
?lexmode MarkupDeclaration; |
?lexmode MarkupDeclaration; |
2431 |
} |
} |
2432 |
|
|
2433 |
|
lang:Perl { |
2434 |
|
$decl->{reptxt} = \$reptxt; |
2435 |
|
} |
2436 |
} // _EntityValueA |
} // _EntityValueA |
2437 |
|
|
2438 |
|
|
2941 |
TAGC := ['>']; |
TAGC := ['>']; |
2942 |
|
|
2943 |
/* |
/* |
2944 |
Empty element tag close |
Null end-tag enabled start-tag close |
2945 |
*/ |
*/ |
2946 |
MTAGC := ['/'] ['>']; |
NESTC := ['/']; |
2947 |
} // StartTag |
} // StartTag |
2948 |
|
|
2949 |
lexmode EndTag |
lexmode EndTag |
3185 |
|
|
3186 |
@XMLTests: |
@XMLTests: |
3187 |
@@XMLTest: |
@@XMLTest: |
3188 |
|
@@@QName: xp.only.docel.test |
3189 |
@@@DEnt: |
@@@DEnt: |
3190 |
@@@@test:value: |
@@@@test:value: |
3191 |
<p></p> |
<p></p> |
3192 |
@@@test:domTree: |
@@@test:domTree: |
3193 |
document { |
document { |
3194 |
xml-version: '1.0'; |
xml-version: '1.0'; |
3195 |
|
xml-encoding: null; |
3196 |
|
xml-standalone: false; |
3197 |
|
element { |
3198 |
|
namespace-uri: null; |
3199 |
|
prefix: null; |
3200 |
|
local-name: 'p'; |
3201 |
|
text-content: ''; |
3202 |
|
} |
3203 |
|
} |
3204 |
|
@@XMLTest: |
3205 |
|
@@@QName: xp.only.docel.emptyelemtag.test |
3206 |
|
@@@DEnt: |
3207 |
|
@@@@test:value: |
3208 |
|
<p/> |
3209 |
|
@@@test:domTree: |
3210 |
|
document { |
3211 |
|
xml-version: '1.0'; |
3212 |
|
xml-encoding: null; |
3213 |
|
xml-standalone: false; |
3214 |
element { |
element { |
3215 |
namespace-uri: null; |
namespace-uri: null; |
3216 |
prefix: null; |
prefix: null; |
3218 |
text-content: ''; |
text-content: ''; |
3219 |
} |
} |
3220 |
} |
} |
3221 |
|
|
3222 |
|
@@XMLTest: |
3223 |
|
@@@QName: xp.doctype.empty.test |
3224 |
|
@@@DEnt: |
3225 |
|
@@@@test:value: |
3226 |
|
<!DOCTYPE a> |
3227 |
|
<a></a> |
3228 |
|
@@@test:domTree: |
3229 |
|
document { |
3230 |
|
xml-version: '1.0'; |
3231 |
|
xml-encoding: null; |
3232 |
|
xml-standalone: false; |
3233 |
|
document-type { |
3234 |
|
node-name: 'a'; |
3235 |
|
} |
3236 |
|
element { |
3237 |
|
namespace-uri: null; |
3238 |
|
prefix: null; |
3239 |
|
local-name: 'a'; |
3240 |
|
text-content: ''; |
3241 |
|
} |
3242 |
|
} |
3243 |
|
|
3244 |
|
@@XMLTest: |
3245 |
|
@@@QName: xp.doctype.intsubset.empty.test |
3246 |
|
@@@DEnt: |
3247 |
|
@@@@test:value: |
3248 |
|
<!DOCTYPE a [ |
3249 |
|
|
3250 |
|
]> |
3251 |
|
<a></a> |
3252 |
|
@@@test:domTree: |
3253 |
|
document { |
3254 |
|
xml-version: '1.0'; |
3255 |
|
xml-encoding: null; |
3256 |
|
xml-standalone: false; |
3257 |
|
document-type { |
3258 |
|
node-name: 'a'; |
3259 |
|
} |
3260 |
|
element { |
3261 |
|
namespace-uri: null; |
3262 |
|
prefix: null; |
3263 |
|
local-name: 'a'; |
3264 |
|
text-content: ''; |
3265 |
|
} |
3266 |
|
} |
3267 |
|
|
3268 |
|
@@XMLTest: |
3269 |
|
@@@QName: xp.doctype.intsubset.pi.test |
3270 |
|
@@@DEnt: |
3271 |
|
@@@@test:value: |
3272 |
|
<!DOCTYPE a [ |
3273 |
|
<?pi data ?> |
3274 |
|
]> |
3275 |
|
<a></a> |
3276 |
|
@@@test:domTree: |
3277 |
|
document { |
3278 |
|
xml-version: '1.0'; |
3279 |
|
xml-encoding: null; |
3280 |
|
xml-standalone: false; |
3281 |
|
document-type { |
3282 |
|
node-name: 'a'; |
3283 |
|
pi { |
3284 |
|
target: 'pi'; |
3285 |
|
data: 'data '; |
3286 |
|
} |
3287 |
|
} |
3288 |
|
element { |
3289 |
|
namespace-uri: null; |
3290 |
|
prefix: null; |
3291 |
|
local-name: 'a'; |
3292 |
|
text-content: ''; |
3293 |
|
} |
3294 |
|
} |
3295 |
|
@@@enImplNote: |
3296 |
|
A DOM PI node in doctype node is a manakai extension. |
3297 |
|
|
3298 |
|
|
3299 |
|
@@XMLTest: |
3300 |
|
@@@QName: xp.doctype.intsubset.entity.general.internal.test |
3301 |
|
@@@DEnt: |
3302 |
|
@@@@test:value: |
3303 |
|
<!DOCTYPE a [ |
3304 |
|
<!ENTITY entity "entity value"> |
3305 |
|
]> |
3306 |
|
<a></a> |
3307 |
|
@@@test:domTree: |
3308 |
|
document { |
3309 |
|
xml-version: '1.0'; |
3310 |
|
xml-encoding: null; |
3311 |
|
xml-standalone: false; |
3312 |
|
document-type { |
3313 |
|
node-name: 'a'; |
3314 |
|
} |
3315 |
|
element { |
3316 |
|
namespace-uri: null; |
3317 |
|
prefix: null; |
3318 |
|
local-name: 'a'; |
3319 |
|
text-content: ''; |
3320 |
|
} |
3321 |
|
} |
3322 |
|
@@XMLTest: |
3323 |
|
@@@QName: xp.doctype.intsubset.entity.parameter.internal.test |
3324 |
|
@@@DEnt: |
3325 |
|
@@@@test:value: |
3326 |
|
<!DOCTYPE a [ |
3327 |
|
<!ENTITY % entity "entity value"> |
3328 |
|
]> |
3329 |
|
<a></a> |
3330 |
|
@@@test:domTree: |
3331 |
|
document { |
3332 |
|
xml-version: '1.0'; |
3333 |
|
xml-encoding: null; |
3334 |
|
xml-standalone: false; |
3335 |
|
document-type { |
3336 |
|
node-name: 'a'; |
3337 |
|
} |
3338 |
|
element { |
3339 |
|
namespace-uri: null; |
3340 |
|
prefix: null; |
3341 |
|
local-name: 'a'; |
3342 |
|
text-content: ''; |
3343 |
|
} |
3344 |
|
} |
3345 |
|
|
3346 |
|
@@XMLTest: |
3347 |
|
@@@QName: xp.doctype.internal.entity.root.element.text.only.test |
3348 |
|
@@@DEnt: |
3349 |
|
@@@@test:value: |
3350 |
|
<!DOCTYPE a [ |
3351 |
|
<!ENTITY entity "entity value"> |
3352 |
|
]> |
3353 |
|
<a>&entity;</a> |
3354 |
|
@@@test:domTree: |
3355 |
|
document { |
3356 |
|
xml-version: '1.0'; |
3357 |
|
xml-encoding: null; |
3358 |
|
xml-standalone: false; |
3359 |
|
document-type { |
3360 |
|
node-name: 'a'; |
3361 |
|
} |
3362 |
|
element { |
3363 |
|
namespace-uri: null; |
3364 |
|
prefix: null; |
3365 |
|
local-name: 'a'; |
3366 |
|
general-entity-reference { |
3367 |
|
node-name: 'entity'; |
3368 |
|
text { |
3369 |
|
data: 'entity value'; |
3370 |
|
} |
3371 |
|
} |
3372 |
|
} |
3373 |
|
} |
3374 |
|
@@XMLTest: |
3375 |
|
@@@QName: xp.doctype.internal.entity.root.element.text.mult.test |
3376 |
|
@@@DEnt: |
3377 |
|
@@@@test:value: |
3378 |
|
<!DOCTYPE a [ |
3379 |
|
<!ENTITY entity "entity value"> |
3380 |
|
]> |
3381 |
|
<a>&entity; and &entity;</a> |
3382 |
|
@@@test:domTree: |
3383 |
|
document { |
3384 |
|
xml-version: '1.0'; |
3385 |
|
xml-encoding: null; |
3386 |
|
xml-standalone: false; |
3387 |
|
document-type { |
3388 |
|
node-name: 'a'; |
3389 |
|
} |
3390 |
|
element { |
3391 |
|
namespace-uri: null; |
3392 |
|
prefix: null; |
3393 |
|
local-name: 'a'; |
3394 |
|
general-entity-reference { |
3395 |
|
node-name: 'entity'; |
3396 |
|
text { |
3397 |
|
data: 'entity value'; |
3398 |
|
} |
3399 |
|
} |
3400 |
|
text { data: ' and '; } |
3401 |
|
general-entity-reference { |
3402 |
|
node-name: 'entity'; |
3403 |
|
text { |
3404 |
|
data: 'entity value'; |
3405 |
|
} |
3406 |
|
} |
3407 |
|
} |
3408 |
|
} |
3409 |
|
@@XMLTest: |
3410 |
|
@@@QName: xp.doctype.internal.entity.root.element.text.element.test |
3411 |
|
@@@DEnt: |
3412 |
|
@@@@test:value: |
3413 |
|
<!DOCTYPE a [ |
3414 |
|
<!ENTITY entity "entity <p>value</p> with <e>element</e> "> |
3415 |
|
]> |
3416 |
|
<a>&entity;</a> |
3417 |
|
@@@test:domTree: |
3418 |
|
document { |
3419 |
|
xml-version: '1.0'; |
3420 |
|
xml-encoding: null; |
3421 |
|
xml-standalone: false; |
3422 |
|
document-type { |
3423 |
|
node-name: 'a'; |
3424 |
|
} |
3425 |
|
element { |
3426 |
|
namespace-uri: null; |
3427 |
|
prefix: null; |
3428 |
|
local-name: 'a'; |
3429 |
|
general-entity-reference { |
3430 |
|
node-name: 'entity'; |
3431 |
|
text { |
3432 |
|
data: 'entity '; |
3433 |
|
} |
3434 |
|
element { |
3435 |
|
namespace-uri: null; |
3436 |
|
prefix: null; |
3437 |
|
local-name: 'p'; |
3438 |
|
text { |
3439 |
|
data: 'value'; |
3440 |
|
} |
3441 |
|
} |
3442 |
|
text { |
3443 |
|
data: ' with '; |
3444 |
|
} |
3445 |
|
element { |
3446 |
|
namespace-uri: null; |
3447 |
|
prefix: null; |
3448 |
|
local-name: 'e'; |
3449 |
|
text { |
3450 |
|
data: 'element'; |
3451 |
|
} |
3452 |
|
} |
3453 |
|
text { |
3454 |
|
data: ' '; |
3455 |
|
} |
3456 |
|
} |
3457 |
|
} |
3458 |
|
} |
3459 |
|
@@XMLTest: |
3460 |
|
@@@QName: xp.doctype.internal.entity.root.element.text.in.ent.test |
3461 |
|
@@@DEnt: |
3462 |
|
@@@@test:value: |
3463 |
|
<!DOCTYPE a [ |
3464 |
|
<!ENTITY entity1 "entity value"> |
3465 |
|
<!ENTITY entity2 "e&entity1;n"> |
3466 |
|
]> |
3467 |
|
<a>&entity2;</a> |
3468 |
|
@@@test:domTree: |
3469 |
|
document { |
3470 |
|
xml-version: '1.0'; |
3471 |
|
xml-encoding: null; |
3472 |
|
xml-standalone: false; |
3473 |
|
document-type { |
3474 |
|
node-name: 'a'; |
3475 |
|
} |
3476 |
|
element { |
3477 |
|
namespace-uri: null; |
3478 |
|
prefix: null; |
3479 |
|
local-name: 'a'; |
3480 |
|
general-entity-reference { |
3481 |
|
node-name: 'entity2'; |
3482 |
|
text { data: 'e'; } |
3483 |
|
general-entity-reference { |
3484 |
|
node-name: 'entity1'; |
3485 |
|
text { |
3486 |
|
data: 'entity value'; |
3487 |
|
} |
3488 |
|
} |
3489 |
|
text { data: 'n'; } |
3490 |
|
} |
3491 |
|
} |
3492 |
|
} |
3493 |
|
|
3494 |
@@PerlDef: |
@@PerlDef: |
3495 |
my $impl = $Message::DOM::ImplementationRegistry->get_implementation ({ |
my $impl = $Message::DOM::ImplementationRegistry->get_implementation ({ |
3496 |
'Core' => '3.0', |
'Core' => '3.0', |
3510 |
$test->ok; |
$test->ok; |
3511 |
} catch Message::Util::IF::DTException with { }; |
} catch Message::Util::IF::DTException with { }; |
3512 |
} |
} |
3513 |
|
|
3514 |
|
@ResourceDef: |
3515 |
|
@@QName: getCopyOfEntityState |
3516 |
|
@@rdf:type: DISPerl|InlineCode |
3517 |
|
@@ForCheck: ManakaiDOM|ForClass |
3518 |
|
@@PerlDef: |
3519 |
|
{%{$self->{$entity_type}->{$entity_name}}, |
3520 |
|
line => 1, column => 1, pos => 0} |
3521 |
##ManakaiXMLParser |
##ManakaiXMLParser |
3522 |
|
|
3523 |
ElementTypeBinding: |
ElementTypeBinding: |
3557 |
Creates a <IF::DOMCore:DOMLocator> object from a token. |
Creates a <IF::DOMCore:DOMLocator> object from a token. |
3558 |
@PerlDef: |
@PerlDef: |
3559 |
$result = { |
$result = { |
3560 |
utf32_offset => pos ($self->{source}), |
utf32_offset => $self->{entity}->[-1]->{pos}, |
3561 |
}; |
}; |
3562 |
@For: ManakaiDOM|ManakaiDOM3 |
@For: ManakaiDOM|ManakaiDOM3 |
3563 |
|
|
3977 |
my $pos = $o-><AG::DOMCore|DOMError.location> |
my $pos = $o-><AG::DOMCore|DOMError.location> |
3978 |
-><AG::DOMCore|DOMLocator.utf32Offset>; |
-><AG::DOMCore|DOMLocator.utf32Offset>; |
3979 |
if ($pos > -1) { |
if ($pos > -1) { |
3980 |
my $src = \($o->{<H::ecore|object>}->{source}); |
my $src = $o->{<H::ecore|object>}->{entity}->[-1]->{reptxt}; |
3981 |
my $start = $pos; |
my $start = $pos; |
3982 |
$start = rindex ($$src, "\x0A", $start - 1) for 0..2; |
$start = rindex ($$src, "\x0A", $start - 1) for 0..2; |
3983 |
$start++; |
$start++; |