While browsing the Abdera parser code I was wondering why FOMBuilder overrides StAXOMBuilder#createOMElement, so I went looking for the source of the method in the parent class and saw the following:

    protected OMNode createOMElement() throws OMException {
        OMElement node;
        String elementName = parser.getLocalName();
        if (lastNode == null) {
node = omfactory.createOMElement(elementName, null, document, this);
        } else if (lastNode.isComplete()) {
            node = omfactory.createOMElement(elementName, null,
lastNode.getParent(), this);
            ((OMNodeEx) lastNode).setNextOMSibling(node);
            ((OMNodeEx) node).setPreviousOMSibling(lastNode);
        } else {
            OMContainerEx e = (OMContainerEx) lastNode;
            node = omfactory.createOMElement(elementName, null,
(OMElement) lastNode, this);
            e.setFirstChild(node);
        }
        populateOMElement(node);
        return node;
    }

Look at those omfactory.createOMElement calls: the second argument is supposed to be a namespace and is always null! Does this mean that AXIOM blithely ignores the namespace of the element the parser has just encountered? I can't believe this is the case.

Is this the reason why we need to override this method, in order to pass the correct namespace?

        Thanks,

                Ugo

Reply via email to