I want to create a new xml doc. I use a method to create the root element of my new xml doc and this method returns me the root element.
Than I create another method to add a child to the root element returned by the first method.
The problem is that when I use this two methods saperately I don't get any result, but when I use only one method to do all the job of this two method I get the expected result.
This is the code when it works ok:
Java Code:
    public static Node setRootElement (Document bpmn_doc){
    		Element rootElement = bpmn_doc.createElement("bpmn2:definitions");
    
    		Element processNode = bpmn_doc.createElement("bpmn2:process");
    		
    		processNode.setAttribute("id", "Definitions_1"); 
    		rootElement.appendChild(processNode);
    		System.out.println(rootElement.getNodeName());
    		System.out.println(processNode.getAttribute("id"));
    
    		return rootElement;
    		
    	}
And the result is :
bpmn2:definitions
Definitions_1


When I use two separate methods to do this job in this way:

Java Code:
    public static Node setRootElement (Document bpmn_doc){
    		Element rootElement = bpmn_doc.createElement("bpmn2:definitions");
    		return rootElement;
    	}

    public static Node appendProcessNode(Document bpmn_doc) {
            Node rootElement = setRootElement(bpmn_doc);
    		Element processNode = bpmn_doc.createElement("bpmn2:process");
                    processNode.setAttribute("id", "Definitions_1");
    		rootElement.appendChild(processNode);
    		System.out.println(rootElement.getNodeName());
        	System.out.println(processNode.getAttribute("id"));
    	    
    	}
i don't get any result ...

Any idea how to resolve this please?