Skip to content

Traversing the Parse Tree starting from a Node of TYPE != ELEMENT not possible. #18

@everga

Description

@everga

Hello Stefan,

When using kxml2 to analyze "unknown" XML documents, I stumbled upon the fact that only nodes of the type ELEMENT are assigned their predecessors. So it is not possible to walk through the parse tree if the start point is not of type ELEMENT Wouldn't it be more sensible if elements of the type COMMENT and TEXT (possibly all) also get their predecessor. Should the memory requirement or the garbage collection be the reason for this decision perhaps using a weake reference for parrent could be the solution.

I hope I haven't overlook other side effects.

in Class:
org.kxml2.kdom.Node.java
at Method:

public void addChild(int index, int type, NodeInterface child) {
[...]
        if (type == ELEMENT) {
            if (!(child instanceof Element))
                throw new RuntimeException("TestElement obj expected)");

            ((Element) child).setParent(this);
        }
[...]
}

Thanks

Best wishes

Andreas

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions