@@ WIP IFClsXDef: @IFQName: SerialWalker @ClsQName: ManakaiDOMSerialWalker @enDesc: {ISSUE:: Better name? } A object can be used to traverse the subtree rooted by a node in document order. Unlike and , the object cannot go back toward nodes that had already been seen. The , however, revisits a node after its children are visited. This might be useful when an application wants to serialize a subtree in a format where delimiter and / or terminator should be inserted between and / or after nodes. How the works is defined by the following reference algorithm. An implementation does not have to implement this exact algorithm, but it implement its method so that it has the same effect as the reference algorithm when the underlying subtree has not been modified. At the time of creation of the , the implementation prepare a queue and initialize it by pushing the node. {P:: When the method is invoked, - If the queue is empty, the method return . It change , , and attributes. {LI:: Otherwise, - Shift a node from the queue. If the node has the phase value, the method return the node. In addition, it set the attribute to the node, the attribute to the associated phase value, and the attribute to the integer value that is large by one than the most recent value when the was same as the shiftted node. If it is the first time the node is set to the attribute, the attribute set to zero. {LI:: Otherwise, determine whether the shifted node should be accepted or not, using , , and attributes, as defined for the interface. {LI:: If the node is ed, = Prepend the node to the queue, with phase value set to . = Prepend the child nodes of the node, if any, to the queue keeping the document order, without phase value. That is, the first child be located at the top (first position) of the queue. = Prepend the node to the queue, with phase value set to . = If the node has a previous sibling in the logical view, preprend the parent node of the node in the logical view, with phase value set to . = Invoke the algorithm recursively. } {LI:: If the node is ped, = Prepend the child nodes of the node, if any, to the queue keeping the document order, without phase value. That is, the first child be located at the top (first position) of the queue. = Invoke the algorithm recursively. } {LI:: If the node is , = Prepend the node to the queue, with phase value set to . = Prepend the node to the queue, with phase value set to . = If the node has a previous sibling in the logical view, preprend the parent node of the node in the logical view, with phase value set to . = Invoke the algorithm recursively. } - Otherwise, invoke the algorithm recursively. } } } {NOTE:: This algorithm will stop unless nodes are simulataneously populated to the underlying tree by application via e.g. . } Implementation choose to implement the using another algorithm. In particular, when the is invoked might vary across implementations. Implementations should try to return the same effect as the reference algorithm even if the underlying subtree is modified, but applications rely on the particular implementation's behavior. As long as the underlying subtree is not modified, a node will never set to the attribute with the of . If the underlying subtree is modified, depending on how the method is implemented, it might be in case. For the purpose of description below, such duplication was considered as if they were different nodes. {P:: Even if the underlying subtree has been modified during the traversal, the implementation ensure the following conditions are met: - A node be set to the attribute with the of or more than once respectively. - A node be set to the attribute with the of before it is once set to the same node with the of , or after it is once set to the same node with the of . - A node be set to the attribute with the of before it is once set to the same node with the of . - A node be set to the attribute with the of later if it is once set to the same node with the of . - The set to unless its value is or . - The set to unless its value is . - The set to unless its value is or . - If a node is set to the attribute and then another node is set to the attribute with both of , the attribute be set to with of before once the attribute is set to with of . - For each time the attribute is set to a node, the be increased by one. If the node is set to the attribute for the first time, the be set to zero. That is, with and only with the can be zero. } @CODE: @@QName: createSWForTest @@PerlDef: __CODE{tc|createEmptyDocumentForTest:: $doc => $doc}__; my $docel = $doc-> ('docel'); $doc-> ($docel); my $doctrv = $doc-> ('Traversal', '2.0'); $sw = $doctrv-> ($docel); @LXAttr: @@Name: root @@enDesc: The root node of the . @@Type: Node @@Get: @@@enDesc: The root node set when the is created. @@@PerlDef: $r = $self->{root}; @LXAttr: @@Name: currentNode @@enDesc: The current node of the . {NOTE:: Unlike , the attribute is read-only. } @@Type: Node @@Get: @@@enDesc: The current node. @@@PerlDef: $r = $self->{current_node}; @mShortConstGroup: @@IFQName: SerialWalkerPhase @@enDesc: An integer to indicate a phase of . @@mConst: @@@Name: PRE_PHASE @@@intValue: 1 @@@enDesc: The is visited by the for the first time. It is expected that the same node will be revisited with of (optionally) and later. @@mConst: @@@Name: IN_PHASE @@@intValue: 2 @@@enDesc: The is visited by the , not for the first or last time, between visitings to its two child nodes. @@mConst: @@@Name: POST_PHASE @@@intValue: 3 @@@enDesc: The is visited by the for the last time. @LXAttr: @@Name: currentPhase @@enDesc: The current phase of the . @@Type: unsignedShort @@actualType: SerialWalkerPhase @@Get: @@@enDesc: An integer to indicate the current phase. @@@PerlDef: $r = $self->{current_phase}; @LXAttr: @@Name: currentIndex @@enDesc: The current index of the . The represents how many times the is exposed through the . @@Type: unsignedLong @@Get: @@@enDesc: An integer to indicate the current index. @@@PerlDef: $r = $self->{current_index}; @LXAttr: @@Name: expandEntityReferences @@enDesc: The value of the flag that determines whether the children of nodes are visible to the . {NOTE:: To produce a view of the document that has entity references expanded and does not expose the nodes themselves, use the flags to hide the nodes and set the flag to when creating the . To produce a view of the document that has nodes but no entity expansion, use the flags to show the nodes and set the flag to when creating the . } @@Type: boolean @@Get: @@@enDesc: The value that was specified when the was created. @@@TrueCase: @@@@enDesc: The children and their descendants of nodes will be rejected. Note that the flags and the set to the might reject them as usual way. @@@FalseCase: @@@@enDesc: The children and their descendants of entity reference nodes will be rejected. This rejection takes precedence over the flags and the set to the , if any. @@@PerlDef: $r = $self->{expand_entity_references}; @LXAttr: @@Name: filter @@enDesc: The filter used to screen nodes. @@Type: NodeFilter @@Get: @@@enDesc: The that was specified when the was created. @@@nullCase: @@@@enDesc: If no was specified when the was created. @@@PerlDef: $r = $self->{filter}; @LXAttr: @@Name: whatToShow @@enDesc: The flags that determines which node types are presented via the . The available set of constants is defined in the interface. Nodes not accepted by the flags will be skipped, but their children may still be considered. This skip takes precedence over the set to the , if any. @@Type: unsignedShort @@actualType: WhatToShow @@Get: @@@enDesc: The value that was specified when the was created. @@@PerlDef: $r = $self->{what_to_show}; @LXMethod: @@Name: nextNode @@enDesc: Returns the node next to the of the . @@Return: @@@Type: Node @@@enDesc: The next node. @@@nullCase: @@@@enDesc: If no next node.