1 package org.objectweb.celtix.tools.utils; 2 3 import org.w3c.dom.*; 4 import org.objectweb.celtix.helpers.XMLUtils; 5 import org.objectweb.celtix.tools.common.ToolConstants; 6 7 public final class JAXBUtils { 8 private JAXBUtils() { 9 } 10 11 private static Node innerJaxbBinding(Element schema) { 12 String schemaNamespace = schema.getNamespaceURI(); 13 Document doc = schema.getOwnerDocument(); 14 15 Element annotation = doc.createElementNS(schemaNamespace, "annotation"); 16 Element appinfo = doc.createElementNS(schemaNamespace, "appinfo"); 17 annotation.appendChild(appinfo); 18 Element jaxbBindings = doc.createElementNS(ToolConstants.NS_JAXB_BINDINGS, "schemaBindings"); 19 appinfo.appendChild(jaxbBindings); 20 return jaxbBindings; 21 } 22 23 public static Node innerJaxbPackageBinding(Element schema, String packagevalue) { 24 Document doc = schema.getOwnerDocument(); 25 XMLUtils xmlUtils = new XMLUtils(); 26 if (!xmlUtils.hasAttribute(schema, ToolConstants.NS_JAXB_BINDINGS)) { 27 schema.setAttributeNS(ToolConstants.NS_JAXB_BINDINGS, "version", "2.0"); 28 } 29 30 Node schemaBindings = innerJaxbBinding(schema); 31 32 Element packagename = doc.createElementNS(ToolConstants.NS_JAXB_BINDINGS, "package"); 33 packagename.setAttribute("name", packagevalue); 34 35 schemaBindings.appendChild(packagename); 36 37 return schemaBindings.getParentNode().getParentNode(); 38 } 39 } 40 | Popular Tags |