OMFactory factory = metaFactory.getOMFactory();
// Create a root element on which we declare the namespaces
OMElement root = factory.createOMElement("root", null);
OMNamespace ns1 = root.declareNamespace("urn:ns1", "ns1");
OMNamespace ns2 = root.declareNamespace("urn:ns2", "ns2");
root.declareNamespace("urn:ns3", "ns3");
// Create a child that uses these namespaces (in the element name and in the name of an attribute)
OMElement child = factory.createOMElement("child", ns1, root);
child.addAttribute("attr", "value", ns2);