abdera-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From James M Snell <jasn...@gmail.com>
Subject Re: AXIOM and namespaces
Date Fri, 07 Dec 2007 17:08:24 GMT
The base impl is rather odd, but in this case, Axiom pulls the
information it needs from the stream reader so it doesn't need the
namespace passed in.  We've overridden this for a number of reasons, the
most important of which is to support the parse filter mechanism so that
things we don't want can be ignored.  Subclassing also makes sure that
our factory is used to create objects so that everything we return to
the user is a FOM object (see the constructNode method in FOMBuilder)

- James

Ugo Cei wrote:
> 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
> 

Mime
View raw message