Java Code Examples for org.dom4j.DocumentHelper#createDocument()

The following examples show how to use org.dom4j.DocumentHelper#createDocument() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: XmlStreamTest.java    From projectforge-webapp with GNU General Public License v3.0 6 votes vote down vote up
@Test
public void testOmitFields()
{
  final XmlObjectWriter writer = new XmlObjectWriter();
  final Document document = DocumentHelper.createDocument();
  final Element root = document.addElement("root");
  final TestObject obj = new TestObject();
  obj.s0 = "s0";
  obj.t0 = "t0";
  obj.color1 = obj.color2 = TestEnum.RED;
  Element el = writer.write(root, obj);
  containsElements(el, "s0");
  containsAttrs(el, "color1", "color2");
  containsNotAttrs(el, "OMIT_STATIC", "omitFinal", "omitTransient", "s0", "t0");
  containsNotElements(el, "t0");
  writer.setOnlyAnnotatedFields(true);
  el = writer.write(root, obj);
  containsNotAttrs(el, "color1", "s0", "t0");
  containsNotElements(el, "s0", "t0");
}
 
Example 2
Source File: EnhanceBaseBuilder.java    From o2oa with GNU Affero General Public License v3.0 6 votes vote down vote up
private static File createPernsistenceXml(List<Class<?>> classes, File directory) throws Exception {
	Document document = DocumentHelper.createDocument();
	Element persistence = document.addElement("persistence", "http://java.sun.com/xml/ns/persistence");
	persistence.addAttribute(QName.get("schemaLocation", "xsi", "http://www.w3.org/2001/XMLSchema-instance"),
			"http://java.sun.com/xml/ns/persistence  http://java.sun.com/xml/ns/persistence/persistence_2_0.xsd");
	persistence.addAttribute("version", "2.0");
	Element unit = persistence.addElement("persistence-unit");
	unit.addAttribute("name", "enhance");
	for (Class<?> o : classes) {
		Element element = unit.addElement("class");
		element.addText(o.getCanonicalName());
	}
	OutputFormat format = OutputFormat.createPrettyPrint();
	format.setEncoding("UTF-8");
	File file = new File(directory, "persistence.xml");
	XMLWriter writer = new XMLWriter(new FileWriter(file), format);
	writer.write(document);
	writer.close();
	return file;
}
 
Example 3
Source File: StudentSectioningQueue.java    From unitime with Apache License 2.0 6 votes vote down vote up
protected static void addItem(org.hibernate.Session hibSession, UserContext user, Long sessionId, Type type, Collection<Long> ids) {
	StudentSectioningQueue q = new StudentSectioningQueue();
	q.setTimeStamp(new Date());
	q.setType(type.ordinal());
	q.setSessionId(sessionId);
	Document d = DocumentHelper.createDocument();
	Element root = d.addElement("generic");
	if (user != null) {
		Element e = root.addElement("user");
		e.addAttribute("id", user.getExternalUserId()).setText(user.getName());
	}
	if (ids != null && !ids.isEmpty()) {
		for (Long id: ids)
			root.addElement("id").setText(id.toString());
	}
	q.setMessage(d);
	hibSession.save(q);
}
 
Example 4
Source File: ResourceUtil.java    From das with Apache License 2.0 6 votes vote down vote up
/**
 * 1-1 创建db xml 并初始化dao
 *
 * @param dbaddress
 * @param dbport
 * @param dbuser
 * @param dbpassword
 * @param db_name
 * @return
 * @throws Exception
 */
public boolean initializeDatasourceXml(String db_name, String dbaddress, String dbport, String dbuser, String dbpassword) throws Exception {
    String connectionUrl = String.format(jdbcUrlTemplate, dbaddress, dbport, db_name);
    Document document = DocumentHelper.createDocument();
    Element root = document.addElement("Datasources");
    root.addElement(DATASOURCE).addAttribute(DATASOURCE_NAME, DATA_BASE)
            .addAttribute(DATASOURCE_USERNAME, dbuser).addAttribute(DATASOURCE_PASSWORD, dbpassword)
            .addAttribute(DATASOURCE_CONNECTION_URL, connectionUrl)
            .addAttribute(DATASOURCE_DRIVER_CLASS, DATASOURCE_MYSQL_DRIVER);
    try (FileWriter fileWriter = new FileWriter(getDbXmlPath())) {
        XMLWriter writer = new XMLWriter(fileWriter);
        writer.write(document);
        writer.close();
    }
    return true;
}
 
Example 5
Source File: ScheduledTask.java    From cuba with Apache License 2.0 5 votes vote down vote up
public void updateMethodParameters(List<MethodParameterInfo> params) {
    Document doc = DocumentHelper.createDocument();
    Element paramsEl = doc.addElement("params");
    for (MethodParameterInfo param : params) {
        Element paramEl = paramsEl.addElement("param");
        paramEl.addAttribute("type", param.getType().getName());
        paramEl.addAttribute("name", param.getName());
        paramEl.setText(param.getValue() != null ? param.getValue().toString() : "");
    }
    setMethodParamsXml(Dom4j.writeDocument(doc, true));
}
 
Example 6
Source File: BatchResponseDsml.java    From directory-ldap-api with Apache License 2.0 5 votes vote down vote up
/**
 * Converts this Batch Response to its XML representation in the DSMLv2 format.
 * 
 * @param prettyPrint if true, formats the document for pretty printing
 * @return the XML representation in DSMLv2 format
 */
public String toDsml( boolean prettyPrint )
{
    Document document = DocumentHelper.createDocument();
    Element element = document.addElement( "batchResponse" );

    element.add( ParserUtils.DSML_NAMESPACE );
    element.add( ParserUtils.XSD_NAMESPACE );
    element.add( ParserUtils.XSI_NAMESPACE );

    // RequestID
    if ( requestID != 0 )
    {
        element.addAttribute( "requestID", Integer.toString( requestID ) );
    }

    for ( DsmlDecorator<? extends Response> response : responses )
    {
        response.toDsml( element );
    }

    if ( prettyPrint )
    {
        document = ParserUtils.styleDocument( document );
    }
    
    return document.asXML();
}
 
Example 7
Source File: ProjectConfigurationWorkingCopy.java    From eclipse-cs with GNU Lesser General Public License v2.1 5 votes vote down vote up
/**
 * Produces the sax events to write a project configuration.
 *
 * @param config
 *          the configuration
 */
private Document writeProjectConfig(ProjectConfigurationWorkingCopy config)
        throws CheckstylePluginException {

  Document doc = DocumentHelper.createDocument();

  Element root = doc.addElement(XMLTags.FILESET_CONFIG_TAG);
  root.addAttribute(XMLTags.FORMAT_VERSION_TAG,
          ProjectConfigurationFactory.CURRENT_FILE_FORMAT_VERSION);
  root.addAttribute(XMLTags.SIMPLE_CONFIG_TAG, Boolean.toString(config.isUseSimpleConfig()));
  root.addAttribute(XMLTags.SYNC_FORMATTER_TAG, Boolean.toString(config.isSyncFormatter()));

  ICheckConfiguration[] workingCopies = config.getLocalCheckConfigWorkingSet().getWorkingCopies();
  for (int i = 0; i < workingCopies.length; i++) {
    writeLocalConfiguration(workingCopies[i], root);
  }

  for (FileSet fileSet : config.getFileSets()) {
    writeFileSet(fileSet, config.getProject(), root);
  }

  // write filters
  for (IFilter filter : config.getFilters()) {
    writeFilter(filter, root);
  }

  return doc;
}
 
Example 8
Source File: PublishUtil.java    From boubei-tss with Apache License 2.0 5 votes vote down vote up
/**
 * 生成单个文章发布文件
 * @param article 
 * @param publishPath
 * @return
 */
public static String publishOneArticle(Article article, String publishPath) {
       // 删除已发布的文章,如果有的话
       String pubUrl = article.getPubUrl();
       if(pubUrl != null) {
           new File(pubUrl).delete();
       }
       
	// 生成发布路径
	File publishDir = new File(publishPath);
	if (!publishDir.exists()) {
		publishDir.mkdirs();
	}
	
	Document doc = DocumentHelper.createDocument();
	doc.setXMLEncoding(ArticleHelper.getSystemEncoding()); //一般:windows “GBK” linux “UTF-8”
	Element articleNode = doc.addElement("Article");
	
       Map<String, Object> articleAttributes = article.getAttributes4XForm(); // 包含文章的所有属性
       articleAttributes.remove("content");
	addValue2XmlNode(articleNode, articleAttributes);
	
	Element contentNode = articleNode.addElement("content");
	contentNode.addCDATA(article.getContent());
       
	// 发布文章对文章附件的处理
	Element eleAtts = articleNode.addElement("Attachments");
       ArticleHelper.addPicListInfo(eleAtts, article.getAttachments());
       
       // 以 “栏目ID_文章ID.xml” 格式命名文章发布的xml文件
       String fileName = article.getChannel().getId() + "_" + article.getId() + ".xml";
	String filePathAndName = publishPath + "/" + fileName;
       FileHelper.writeXMLDoc(doc, filePathAndName);
	return filePathAndName;
}
 
Example 9
Source File: GanttChartDao.java    From projectforge-webapp with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Writes all Gantt objects as tree as xml. Writes only those values which are different to the original values of the task with the same
 * id.
 * @param obj
 * @param rootObject
 */
public void writeGanttObjects(final GanttChartDO obj, final GanttTask rootObject)
{
  final Document document = DocumentHelper.createDocument();
  final Element element = getXmlGanttObjectWriter().write(document, rootObject);
  // Now, remove all elements with no information from the DOM:
  final String xml;
  if (removeUnnecessaryElements(element) == true) {
    // Nothing to write (no further information in the GanttObject tree given).
    xml = "";
  } else {
    xml = XmlHelper.toString(element);
  }
  obj.setGanttObjectsAsXml(xml);
}
 
Example 10
Source File: RobocupFormat.java    From rcrs-server with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public Document write(GMLMap map) {
    Element root = DocumentHelper.createElement(RCR_ROOT_QNAME);
    Document result = DocumentHelper.createDocument(root);
    writeNodes(map, root.addElement(RCR_NODE_LIST_QNAME));
    writeEdges(map, root.addElement(RCR_EDGE_LIST_QNAME));
    writeShapes(map.getBuildings(), RCR_BUILDING_QNAME, root.addElement(RCR_BUILDING_LIST_QNAME));
    writeShapes(map.getRoads(), RCR_ROAD_QNAME, root.addElement(RCR_ROAD_LIST_QNAME));
    writeShapes(map.getSpaces(), RCR_SPACE_QNAME, root.addElement(RCR_SPACE_LIST_QNAME));
    return result;
}
 
Example 11
Source File: WebAbstractDataGrid.java    From cuba with Apache License 2.0 5 votes vote down vote up
@Override
public void applySettings(Element element) {
    if (!isSettingsEnabled()) {
        return;
    }

    if (defaultSettings == null) {
        defaultSettings = DocumentHelper.createDocument();
        defaultSettings.setRootElement(defaultSettings.addElement("presentation"));
        // init default settings
        saveSettings(defaultSettings.getRootElement());
    }

    Element columnsElem = element.element("columns");
    if (columnsElem != null) {
        List<Column<E>> modelColumns = getVisibleColumns();
        List<String> modelIds = modelColumns.stream()
                .map(String::valueOf)
                .collect(Collectors.toList());

        List<String> loadedIds = columnsElem.elements("columns").stream()
                .map(colElem -> colElem.attributeValue("id"))
                .collect(Collectors.toList());

        if (CollectionUtils.isEqualCollection(modelIds, loadedIds)) {
            applyColumnSettings(element, modelColumns);
        }
    }
}
 
Example 12
Source File: CurModel.java    From unitime with Apache License 2.0 4 votes vote down vote up
public static void main(String[] args) {
 	try {
 		Logger.getRootLogger().setLevel(Level.DEBUG);
 		
 		List<CurStudent> students = new ArrayList<CurStudent>();
 		for (int i = 0; i < 20; i++)
 			students.add(new CurStudent(new Long(1 + i), (i < 10 ? 0.5f: 2f)));
 		CurModel m = new CurModel(students);
 		for (int i = 1; i <= 10; i++)
 			m.addCourse((long)i, "C" + i,  2 * i, null);
 		for (int i = 1; i < 10; i++)
 			for (int j = i + 1; j <= 10; j++)
 				m.setTargetShare((long)i, (long)j, i, false);
 		m.setStudentLimits();
 		
Document d0 = DocumentHelper.createDocument();
Assignment<CurVariable, CurValue> a = new DefaultSingleAssignment<CurVariable, CurValue>();
m.saveAsXml(d0.addElement("curriculum"), a);
sLog.info(d0.asXML());

 		sLog.info("Loaded: " + ToolBox.dict2string(m.getInfo(a), 2));

 		m.solve(a);

 		sLog.info("Solution: " + ToolBox.dict2string(m.getInfo(a), 2));
 		
Document d1 = DocumentHelper.createDocument();
m.saveAsXml(d1.addElement("curriculum"), a);
sLog.info(d1.asXML());

Solution<CurVariable, CurValue> x = loadFromXml(d1.getRootElement());
sLog.info("Reloaded: " + ToolBox.dict2string(x.getInfo(), 2));
         
 		TreeSet<CurCourse> courses = new TreeSet<CurCourse>(new Comparator<CurCourse>() {
 			public int compare(CurCourse c1, CurCourse c2) {
 				int cmp = c1.getCourseName().compareTo(c2.getCourseName());
 				if (cmp != 0) return cmp;
 				return c1.getCourseId().compareTo(c2.getCourseId());
 			}
 		});
 		courses.addAll(m.getCourses());
         int penalty = 0;
 		for (CurCourse course: courses) {
 			sLog.info(course.getCourseName() + ": " + m.getCourse(course.getCourseId()).getStudents(a) + " (" + course.getSize(a) + "/" + course.getOriginalMaxSize() + ")");
     		for (CurCourse other: courses) {
     			if (other.getCourseId() <= course.getCourseId()) continue;
 				double share = course.share(a, other);
 				double target = course.getTargetShare(other.getCourseId());
 				sLog.info("  " + other.getCourseName() + ": share=" + share + ", target=" + target + ", penalty=" + Math.abs(target - share)); 
 				penalty += Math.abs(target - share);
 			}
 		}
 		sLog.info("Total penalty: " + penalty);
 		
Document doc = DocumentHelper.createDocument();
m.saveAsXml(doc.addElement("curriculum"), a);
FileOutputStream fos = new FileOutputStream("/Users/muller/solution.xml");
         (new XMLWriter(fos, OutputFormat.createPrettyPrint())).write(doc);
         fos.flush();
         fos.close();

 	} catch (Exception e) {
 		e.printStackTrace();
 	}
 }
 
Example 13
Source File: DOM4JSerializer.java    From pushfish-android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static DOM4JSettingsNode createBlankSettings() {
    Document document = DocumentHelper.createDocument();
    Element rootElement = document.addElement("root");
    DOM4JSettingsNode settings = new DOM4JSettingsNode(rootElement);
    return settings;
}
 
Example 14
Source File: XMLUtil.java    From APICloud-Studio with GNU General Public License v3.0 4 votes vote down vote up
/**
 * 创建XML文件
 * @return
 */
private static Document testCreateXMLFile() {
    // 使用DocumentHelper.createDocument方法建立一个文档实例
    Document document = DocumentHelper.createDocument();
    // 使用addElement方法方法创建根元素
    Element catalogElement = document.addElement("catalog");
    // 使用addComment方法方法向catalog元素添加注释
    catalogElement.addComment("使用addComment方法方法向catalog元素添加注释");
    // 使用addProcessInstruction向catalog元素增加处理指令
    catalogElement.addProcessingInstruction("target", "text");

    // 使用addElement方法向catalog元素添加journal子元素
    Element journalElement = catalogElement.addElement("journal");
    // 使用addAttribute方法向journal元素添加title和publisher属性
    journalElement.addAttribute("title", "XML Zone");
    journalElement.addAttribute("publisher", "Willpower Co");

    // 使用addElement方法向journal元素添加article子元素
    Element articleElement = journalElement.addElement("article");
    // 使用addAttribute方法向article元素添加level和date属性
    articleElement.addAttribute("level", "Intermediate");
    articleElement.addAttribute("date", "July-2006");

    // 使用addElement方法向article元素添加title子元素
    Element titleElement = articleElement.addElement("title");
    // 使用setText方法设置title子元素的值
    titleElement.setText("Dom4j Create XML Schema");

    // 使用addElement方法向article元素添加authorElement子元素
    Element authorElement = articleElement.addElement("author");

    // 使用addElement方法向author元素添加firstName子元素
    Element firstName = authorElement.addElement("fistname");
    // 使用setText方法设置firstName子元素的值
    firstName.setText("Yi");

    // 使用addElement方法向author元素添加lastname子元素
    Element lastName = authorElement.addElement("lastname");
    // 使用setText方法设置lastName子元素的值
    lastName.setText("Qiao");

    return document;
}
 
Example 15
Source File: DomHelper.java    From Crawer with MIT License 4 votes vote down vote up
/**
  * 创建document
  * @return
  */
public static Document createDomFJ(){
	Document doc =DocumentHelper.createDocument();
	return doc;
}
 
Example 16
Source File: CommonDao.java    From jeecg with Apache License 2.0 4 votes vote down vote up
/**
 * 生成XML importFile 导出xml工具类
 */
public HttpServletResponse createXml(ImportFile importFile) {
	HttpServletResponse response = importFile.getResponse();
	HttpServletRequest request = importFile.getRequest();
	try {
		// 创建document对象
		Document document = DocumentHelper.createDocument();
		document.setXMLEncoding("UTF-8");
		// 创建根节点
		String rootname = importFile.getEntityName() + "s";
		Element rElement = document.addElement(rootname);
		Class entityClass = importFile.getEntityClass();
		String[] fields = importFile.getField().split(",");
		// 得到导出对象的集合
		List objList = loadAll(entityClass);
		Class classType = entityClass.getClass();
		for (Object t : objList) {
			Element childElement = rElement.addElement(importFile.getEntityName());
			for (int i = 0; i < fields.length; i++) {
				String fieldName = fields[i];
				// 第一为实体的主键
				if (i == 0) {
					childElement.addAttribute(fieldName, String.valueOf(TagUtil.fieldNametoValues(fieldName, t)));
				} else {
					Element name = childElement.addElement(fieldName);
					name.setText(String.valueOf(TagUtil.fieldNametoValues(fieldName, t)));
				}
			}

		}
		String ctxPath = request.getSession().getServletContext().getRealPath("");
		File fileWriter = new File(ctxPath + "/" + importFile.getFileName());
		XMLWriter xmlWriter = new XMLWriter(new FileOutputStream(fileWriter));

		xmlWriter.write(document);
		xmlWriter.close();
		// 下载生成的XML文件
		UploadFile uploadFile = new UploadFile(request, response);
		uploadFile.setRealPath(importFile.getFileName());
		uploadFile.setTitleField(importFile.getFileName());
		uploadFile.setExtend("bak");
		viewOrDownloadFile(uploadFile);
	} catch (Exception e) {
		e.printStackTrace();
	}
	return response;
}
 
Example 17
Source File: ComponentAction.java    From boubei-tss with Apache License 2.0 4 votes vote down vote up
/**
    * 在线编辑组件参数配置  
    */
@RequestMapping("/paramconfig/{id}")
   public void getComponentParamsConfig(HttpServletResponse response, HttpServletRequest request, 
   		@PathVariable("id") Long id) {
	
       Component component = service.getComponent(id);
      
       String configFilePath = URLUtil.getWebFileUrl(component.getResourcePath() + "/" + Component.PARAM_FILE).getFile();
       if( !new File(configFilePath).exists() ) {
           // 如果是第一次配置,且配置参数项不为空,则根据需要的参数项自动生成一个默认模板
           Document doc = DocumentHelper.createDocument();
           Element xformNode = doc.addElement("Response").addElement("ConfigParams").addElement("xform");
           Element declareNode = xformNode.addElement("declare");
           Element layoutNode = xformNode.addElement("layout");
           xformNode.addElement("data");
           
           //  paramsItem 格式类似 :" bgColor=red \n menuId=12 "
           String paramsItem = EasyUtils.obj2String( request.getParameter("paramsItem") );
           StringTokenizer stk = new StringTokenizer(paramsItem);
           while(stk.hasMoreTokens()) {
               String itemName = stk.nextToken(); 
               int index = itemName.indexOf("=");
               itemName = itemName.substring(0, index);
               
               //<column name="tableWidth" caption="XX" mode="string"/>
               Element itemcolumn = declareNode.addElement("column");
               itemcolumn.addAttribute("name", itemName);
               itemcolumn.addAttribute("caption", itemName);
               itemcolumn.addAttribute("mode", "string");
               
               /*<TR>
                *   <TD width="50"><label binding="tableWidth"/></TD>
                *   <TD><input binding="tableWidth" type="text"/></TD>
                *</TR>
                */
               Element trNode = layoutNode.addElement("TR");
               Element tdNode1 = trNode.addElement("TD");
               tdNode1.addAttribute("width", "50");
               Element labelNode = tdNode1.addElement("label");
               labelNode.addAttribute("binding", itemName);
               
               Element tdNode2 = trNode.addElement("TD");
               Element inputNode = tdNode2.addElement("input");
               inputNode.addAttribute("binding", itemName);
               inputNode.addAttribute("type", "text");
		}
		File dir = new File(configFilePath).getParentFile();
		FileHelper.createDir(dir.getPath());

		FileHelper.writeXMLDoc(doc, configFilePath);
		print(XMLDocUtil.createDocByAbsolutePath(configFilePath).asXML());
       } 
       else {
           print(XMLDocUtil.createDocByAbsolutePath(configFilePath).asXML());
       }
   }
 
Example 18
Source File: DOM4JSerializer.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 4 votes vote down vote up
public static DOM4JSettingsNode createBlankSettings() {
    Document document = DocumentHelper.createDocument();
    Element rootElement = document.addElement("root");
    DOM4JSettingsNode settings = new DOM4JSettingsNode(rootElement);
    return settings;
}
 
Example 19
Source File: Simplicity.java    From MesquiteCore with GNU Lesser General Public License v3.0 4 votes vote down vote up
public  void renameSettingsFile(int i, String newName){
	if (!MesquiteInteger.isCombinable(i) || i<0 || i>= InterfaceManager.settingsFiles.size())
		return;
	StringArray s = (StringArray)InterfaceManager.settingsFiles.elementAt(i);
	String path = s.getValue(PATH);
	String settingsXML = s.getValue(XML);
	Element root = XMLUtil.getRootXMLElementFromString("mesquite",settingsXML);
	if (root==null)
		return;
	Element element = root.element("simplicitySettings");
	if (element != null) {
		Element versionElement = element.element("version");
		if (versionElement == null)
			return ;
		else {
			int version = MesquiteInteger.fromString(element.elementText("version"));
			boolean acceptableVersion = version==1;
			if (acceptableVersion) {
				Element name = element.element("name");

				Element settingsFile = DocumentHelper.createElement("mesquite");
				Document doc = DocumentHelper.createDocument(settingsFile);
				Element hidden = DocumentHelper.createElement("simplicitySettings");
				settingsFile.add(hidden);
				XMLUtil.addFilledElement(hidden, "version","1");
				XMLUtil.addFilledElement(hidden, "name",newName);
				Element hp = element.element("hiddenPackages");
				element.remove(hp);
				hidden.add(hp);
				hp = element.element("hiddenMenuItems");
				element.remove(hp);
				hidden.add(hp);
				hp = element.element("hiddenTools");
				element.remove(hp);
				hidden.add(hp);
				s.setName(newName);
				MesquiteFile.putFileContents(path, XMLUtil.getDocumentAsXMLString(doc), false);
			}
		} 
	}
}
 
Example 20
Source File: UnifiedXmlDataShapeSupport.java    From syndesis with Apache License 2.0 4 votes vote down vote up
@Override
public DataShape createShapeFromRequest(final ObjectNode json, final T openApiDoc, final O operation) {
    final Document document = DocumentHelper.createDocument();

    final Element schemaSet = document.addElement("d:SchemaSet", SCHEMA_SET_NS);
    schemaSet.addNamespace(XmlSchemaHelper.XML_SCHEMA_PREFIX, XmlSchemaHelper.XML_SCHEMA_NS);

    final Element schema = XmlSchemaHelper.addElement(schemaSet, "schema");
    schema.addAttribute("targetNamespace", SYNDESIS_REQUEST_NS);
    schema.addAttribute("elementFormDefault", "qualified");

    final Element parametersSchema = createParametersSchema(openApiDoc, operation);

    final Map<String, SchemaPrefixAndElement> moreSchemas = new HashMap<>();

    final Element bodySchema = createRequestBodySchema(openApiDoc, operation, moreSchemas);

    if (bodySchema == null && parametersSchema == null) {
        return DATA_SHAPE_NONE;
    }

    final Element element = XmlSchemaHelper.addElement(schema, ELEMENT);
    element.addAttribute(NAME, "request");
    final Element sequence = XmlSchemaHelper.addElement(element, COMPLEX_TYPE, SEQUENCE);

    final Element additionalSchemas = schemaSet.addElement("d:AdditionalSchemas");

    if (parametersSchema != null) {
        final Element parameters = XmlSchemaHelper.addElement(sequence, ELEMENT);
        parameters.addNamespace("p", SYNDESIS_PARAMETERS_NS);
        parameters.addAttribute(REF, "p:parameters");

        additionalSchemas.add(parametersSchema.detach());
    }

    if (bodySchema != null) {
        final Element bodyElement = XmlSchemaHelper.addElement(sequence, ELEMENT);
        bodyElement.addAttribute(NAME, "body");

        final Element body = XmlSchemaHelper.addElement(bodyElement, COMPLEX_TYPE, SEQUENCE, ELEMENT);
        final String bodyTargetNamespace = bodySchema.attributeValue("targetNamespace");

        final String bodyElementName = bodySchema.element(ELEMENT).attributeValue(NAME);
        if (bodyTargetNamespace != null) {
            body.addNamespace("b", bodyTargetNamespace);
            body.addAttribute(REF, "b:" + bodyElementName);
        } else {
            body.addAttribute(REF, bodyElementName);
        }

        additionalSchemas.add(bodySchema.detach());
    }

    moreSchemas.values().forEach(e -> additionalSchemas.add(e.schema.detach()));

    final String xmlSchemaSet = XmlSchemaHelper.serialize(document);

    return new DataShape.Builder()//
        .kind(DataShapeKinds.XML_SCHEMA)//
        .name("Request")//
        .description("API request payload")//
        .specification(xmlSchemaSet)//
        .putMetadata(DataShapeMetaData.UNIFIED, "true")
        .build();
}