[19] This page describes how source positions of nodes, attributes, tokens, and errors are stored and handled in manakai's DOM/HTML related Perl modules.
[2] A DocumentIndex is a positive integer used to identify a source data stream.
[3] The value -1
represents that the source is an unknown data stream.
[4] A CharacterIndex is a non-negative integer representing the location of a character in the given source character stream. It is the offset from the beginning of the character string.
[43] A LineNumber is a positive integer representing the line in the given source character stream in which the character appears.
[47] The LineNumber of the first line in the source character stream is 1.
[45] A ColumnNumber is a non-negative integer representing the column in the line in the given source character stream at which the character appears.
[46] The ColumnNumber of the first character in the line is 1.
[48] The ColumnNumber of the newline can be 0 (a ColumnNumber in the next line) or equal to the number of the characters in the previous line (a ColumnNumber in the previous line).
[6] An IndexedStringSegment is an array reference containing a character string, a DocumentIndex, and a CharacterIndex.
[7] The pair of the DocumentIndex and the CharacterIndex identifies the source location of the first character of the character string.
[8] An IndexedStringSegment represents the character string.
[1] An IndexedString is an array reference containing zero or more IndexedStringSegment, representing a string consist of concatenation of strings represented by the IndexedStringSegments, in order.
[22] An IndexIndexMappingSegment is an array reference whose items are a CharacterIndex, a DocumentIndex, and a CharacterIndex.
[23] It represents that the character at the first CharacterIndex is corresponding to the character at the last CharacterIndex in the document identified by the DocumentIndex.
[24] An IndexIndexMapping is an array reference whose items are zero or more IndexIndexMappingSegments.
[25] The first CharacterIndex in an earlier IndexIndexMappingSegment in the IndexIndexMapping must be less than or equal to the first CharacterIndex of a later IndexIndexMappingSegment.
[35] It defines a mapping from the CharacterIndex of a character to a pair of DocumentIndex and CharacterIndex.
[29] The relevant segment of a mapping for a CharacterIndex is the result of these steps:
[26] The mapped (DocumentIndex, CharacterIndex) pair of a character obtained by an IndexIndexMapping is the pair of DocumentIndex and the last CharacterIndex of the relevant segment of the IndexIndexMapping for the CharacterIndex identifying the character.
[36] An IndexLCMappingSegment is an array reference whose items are a CharacterIndex, a LineNumber, and a ColumnNumber.
[37] It represents that the character at the CharacterIndex has LineNumber and ColumnNumber.
[38] An IndexLCMapping is an array reference whose items are zero or more IndexLCMappingSegments.
[39] The CharacterIndex in an earlier IndexLCMappingSegment in the IndexLCMapping must be less than or equal to the CharacterIndex of a later IndexLCMappingSegment.
[40] It defines a mapping from the CharacterIndex of a character to a pair of LineNumber and ColumnNumber.
[41] The mapped (LineNumber, ColumnNumber) pair of a character obtained by an IndexLCMapping is the pair of LineNumber and the ColumnNumber of the relevant segment of the IndexLCMapping for the CharacterIndex identifying the character.
[50] A DocumentIndexData is a hash reference. It contains properties of a document.
[51] If there is key map
, its value must be an IndexIndexMapping.
Its IndexIndexMappingSegments' first CharacterIndexes are considered as
indexes in this document.
[52] If there is key lc_map
, its value must be an IndexLCMapping.
Its IndexLCMappingSegments' first CharacterIndexes are considered as
indexes in this document.
[27] If there is key url
, its value must be a character string.
It is the URL of the document, if known. It must be an absolute URL.
However, the consumer of the value must not assume that it is an absolute URL.
[55] Applications can use other keys for their own purposes. They should perform their best effort to avoid conflicting of keys with future addition and of another applications.
[53] A DocumentIndexDataSet is an array reference whose items are DocumentIndexData or undef.
[54] If the i-th item in the array reference is a DocumentIndexData, it is the DocumentIndexData for the document whose DocumentIndex is i. If the i-th item in the array reference is undef, or there is no i-th item in the array reference, DocumentIndex i is not assigned to any document.
[9] If the type of an argument is IndexedStringSegment, run these steps:
[10] If the type of an argument is IndexedString, run these steps:
Node
extensions[11] Each Node
and Attr
has associated
source document index and source character index. Initially, they are unset.
[12] The manakaiGetSourceLocation
method MUST
run these steps:
[13] The manakaiSetSourceLocation
method MUST
run these steps:
[14] The data of a CharacterData
node,
the value of an AttributeDefinition
node, and
the value of an Attr
object are internally stored
as IndexedString (or equivalent).
[15] When they are to be modified by a method that does not aware of IndexedString,
it MUST be performed in a way that does not make DocumentIndex and CharactrIndex
contained in the IndexedString incorrect. When it is not desired to preserve
DocumentIndex and CharacterIndex of affected IndexedStringSegments
or when a DOMString
is inserted, their DocumentIndex
and CharacterIndex MUST be set to -1 and 0, respectively.
[16] The manakaiGetIndexedString
method
MUST return a new IndexedString which represents the same
string as the textContent
attribute
of the context object. DocumentIndex and CharacterIndex contained
in it MUST be set to appropriate values.
[17] The manakaiAppendIndexedString
method
MUST act as if the manakaiAppendText
method is invoked with the character string of the IndexedString argument.
In addition, DocumentIndex and CharacterIndex contained in the IndexedString
argument MUST be used to update the data or value of relevant
objects.
[20] The manakaiGetAttributeIndexedStringNS
method MUST
act as if the getAttributeNS
method is invoked, except
the method MUST return a new IndexedString
instead of a DOMString
.
[21] The manakaiSetAttributeIndexedStringNS
method MUST
act as if the setAttributeNS
method is invoked
with same namespace and name arguments,
and value argument which is a DOMString
equivalent to
the character string of the IndexedString argument.
In addition, DocumentIndex and CharacterIndex contained in the IndexedString
argument MUST be used to set the value of the attribute.
-1
will be used.