01: package org.objectweb.celtix.tools.utils;
02:
03: import org.w3c.dom.*;
04: import org.objectweb.celtix.helpers.XMLUtils;
05: import org.objectweb.celtix.tools.common.ToolConstants;
06:
07: public final class JAXBUtils {
08: private JAXBUtils() {
09: }
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,
16: "annotation");
17: Element appinfo = doc.createElementNS(schemaNamespace,
18: "appinfo");
19: annotation.appendChild(appinfo);
20: Element jaxbBindings = doc.createElementNS(
21: ToolConstants.NS_JAXB_BINDINGS, "schemaBindings");
22: appinfo.appendChild(jaxbBindings);
23: return jaxbBindings;
24: }
25:
26: public static Node innerJaxbPackageBinding(Element schema,
27: String packagevalue) {
28: Document doc = schema.getOwnerDocument();
29: XMLUtils xmlUtils = new XMLUtils();
30: if (!xmlUtils.hasAttribute(schema,
31: ToolConstants.NS_JAXB_BINDINGS)) {
32: schema.setAttributeNS(ToolConstants.NS_JAXB_BINDINGS,
33: "version", "2.0");
34: }
35:
36: Node schemaBindings = innerJaxbBinding(schema);
37:
38: Element packagename = doc.createElementNS(
39: ToolConstants.NS_JAXB_BINDINGS, "package");
40: packagename.setAttribute("name", packagevalue);
41:
42: schemaBindings.appendChild(packagename);
43:
44: return schemaBindings.getParentNode().getParentNode();
45: }
46: }
|