Hi all,

having following code I always get null which I do not understand:
OMFactory factory = OMAbstractFactory.getOMFactory();
StAXOMBuilder builder = new StAXOMBuilder();
...
 String[] tokenizer = rootPath.split("/");
    // create all nodes that are in the root path
    LinkedHashSet<OMElement> path = new LinkedHashSet<OMElement>();
    int i = 0;
    for (String pathPart : tokenizer) {
      if (!pathPart.equals("")) {
        OMElement element = factory.createOMElement(pathPart, null);
        path.add(element);
      }
    }
    // now we have all nodes created but with no hierarchy 
    OMElement[] elements = new OMElement[0];
    elements= path.toArray(new OMElement[path.size()]);
    // create the hierarchy by adding the last node to the 
    // previous one till we reached the first one.
    for (int j = elements.length-1; j > 0; j--) {
      elements[j-1].addChild(elements[j]); 
    }
    // Get rid of the overhead and expose just one node
    OMElement root = elements[0];
...
     AXIOMXPath xpath = new AXIOMXPath("/html/body");
     OMElement injectionPoint = (OMElement)xpath.selectSingleNode(root);
...

When I debug the code I get for root: 
root    OMElementImpl  (id=61)  
        attributes      null    
        builder null    
        done    true    
        factory OMLinkedListImplFactory  (id=50)        
        firstChild      OMElementImpl  (id=80)  
        lastChild       OMElementImpl  (id=80)  
        lineNumber      0       
        localName       "html" (id=84)  
        namespaces      null    
        nextSibling     null    
        nodeType        0       
        noPrefixNamespaceCounter        0       
        ns      null    
        parent  null    
        previousSibling null    

but then for xpath.selectSingleNode(root) it always returns null. 

I am doing obvious something wrong, but I am not sure what. Is there
some obvious problem?

salu2
-- 
Thorsten Scherler                                 thorsten.at.apache.org
Open Source Java                      consulting, training and solutions

Reply via email to