List of usage examples for org.dom4j Element addNamespace
Element addNamespace(String prefix, String uri);
From source file:org.nuxeo.ecm.platform.pictures.tiles.serializer.XMLPictureTilesSerializer.java
License:Open Source License
public String serialize(PictureTiles tiles) { org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(rootTag); rootElem.addNamespace(picturetilesNSPrefix, picturetilesNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); // tile info//from w w w . j a va 2s . c om org.dom4j.Element tileInfo = rootElem.addElement("tileInfo"); tileInfo.addElement("zoom").setText(tiles.getZoomfactor() + ""); tileInfo.addElement("maxTiles").setText(tiles.getMaxTiles() + ""); tileInfo.addElement("tileWidth").setText(tiles.getTilesWidth() + ""); tileInfo.addElement("tileHeight").setText(tiles.getTilesHeight() + ""); tileInfo.addElement("xTiles").setText(tiles.getXTiles() + ""); tileInfo.addElement("yTiles").setText(tiles.getYTiles() + ""); // original img info org.dom4j.Element originalInfo = rootElem.addElement("originalImage"); ImageInfo oInfo = tiles.getOriginalImageInfo(); dumpImageInfo(oInfo, originalInfo); // source img info org.dom4j.Element srcInfo = rootElem.addElement("srcImage"); ImageInfo sInfo = tiles.getSourceImageInfo(); dumpImageInfo(sInfo, srcInfo); // dump misc info returned by the tiler org.dom4j.Element addInfo = rootElem.addElement("additionalInfo"); for (String k : tiles.getInfo().keySet()) { org.dom4j.Element propElem = addInfo.addElement(k); propElem.setText(tiles.getInfo().get(k)); } // debug info org.dom4j.Element debugInfo = rootElem.addElement("debug"); debugInfo.addElement("cacheKey").setText(tiles.getCacheKey()); debugInfo.addElement("formatKey").setText(tiles.getTileFormatCacheKey()); debugInfo.addElement("tilePath").setText(tiles.getTilesPath()); return rootDoc.asXML(); }
From source file:org.nuxeo.ecm.platform.publisher.remoting.marshaling.DefaultDocumentLocationMarshaler.java
License:Open Source License
public String marshalDocumentLocation(DocumentLocation docLoc) throws PublishingMarshalingException { org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(rootTag); rootElem.addNamespace(publisherSerializerNSPrefix, publisherSerializerNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); rootElem.addAttribute("repository", docLoc.getServerName()); rootElem.addAttribute("ref", docLoc.getDocRef().toString()); if (sourceServer != null) { rootElem.addAttribute("originalServer", sourceServer); }//from w ww . ja v a2 s. co m String data = rootDoc.asXML(); return cleanUpXml(data); }
From source file:org.nuxeo.ecm.platform.publisher.remoting.marshaling.DefaultMarshaler.java
License:Open Source License
protected String buildParameterEnvelope(int nbParams) { org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(rootParametersTag); rootElem.addNamespace(publisherSerializerNSPrefix, publisherSerializerNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); for (int i = 1; i <= nbParams; i++) { org.dom4j.Element pathElem = rootElem.addElement(parameterTag); pathElem.setText(PARAM_PATTERN + i + "$"); }//from www. ja v a 2s. c o m return rootDoc.asXML(); }
From source file:org.nuxeo.ecm.platform.publisher.remoting.marshaling.DefaultMarshaler.java
License:Open Source License
protected String buildResultEnvelope() { org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(rootResultTag); rootElem.addNamespace(publisherSerializerNSPrefix, publisherSerializerNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); rootElem.setText(RESULT_PATTERN);/* w w w . j a va2s . co m*/ return rootDoc.asXML(); }
From source file:org.nuxeo.ecm.platform.publisher.remoting.marshaling.DefaultPublicationNodeMarshaler.java
License:Open Source License
public String marshalPublicationNode(PublicationNode node) throws PublishingMarshalingException { org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(rootTag); rootElem.addNamespace(publisherSerializerNSPrefix, publisherSerializerNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); org.dom4j.Element pathElem = rootElem.addElement(nodePathTag); pathElem.setText(node.getPath());//from ww w . j av a 2 s. c o m org.dom4j.Element titleElem = rootElem.addElement(nodeTitleTag); try { titleElem.setText(node.getTitle()); } catch (ClientException e) { throw new PublishingMarshalingException(e); } org.dom4j.Element typeElem = rootElem.addElement(nodeTypeTag); typeElem.setText(node.getNodeType()); org.dom4j.Element treeElem = rootElem.addElement(treeNameTag); treeElem.setText(node.getTreeConfigName()); org.dom4j.Element sidElem = rootElem.addElement(sidTag); if (node.getSessionId() != null) { sidElem.setText(node.getSessionId()); } else { sidElem.setText(""); } String data = rootDoc.asXML(); return cleanUpXml(data); }
From source file:org.nuxeo.ecm.platform.publisher.remoting.marshaling.DefaultPublishedDocumentMarshaler.java
License:Open Source License
public String marshalPublishedDocument(PublishedDocument pubDoc) { if (pubDoc == null) return ""; org.dom4j.Element rootElem = DocumentFactory.getInstance().createElement(rootTag); rootElem.addNamespace(publisherSerializerNSPrefix, publisherSerializerNS); org.dom4j.Document rootDoc = DocumentFactory.getInstance().createDocument(rootElem); org.dom4j.Element sourceElem = rootElem.addElement(sourceRefTag); sourceElem.setText(pubDoc.getSourceDocumentRef().toString()); org.dom4j.Element repoElem = rootElem.addElement(repositoryNameTag); repoElem.setText(pubDoc.getSourceRepositoryName()); org.dom4j.Element srvElem = rootElem.addElement(serverNameTag); srvElem.setText(pubDoc.getSourceServer()); org.dom4j.Element versionElem = rootElem.addElement(versionLabelTag); versionElem.setText("" + pubDoc.getSourceVersionLabel()); org.dom4j.Element pathElem = rootElem.addElement(pathTag); pathElem.setText("" + pubDoc.getPath()); org.dom4j.Element parentPathElem = rootElem.addElement(parentPathTag); parentPathElem.setText("" + pubDoc.getParentPath()); org.dom4j.Element isPendingElem = rootElem.addElement(isPendingTag); isPendingElem.setText("" + pubDoc.isPending()); String data = rootDoc.asXML(); return cleanUpXml(data); }
From source file:org.nuxeo.ecm.platform.ui.web.restAPI.OpenSearchRestlet.java
License:Open Source License
@Override public void handle(Request req, Response res) { CoreSession session;//w w w .j a v a2s . c o m try { Repository repository = Framework.getService(RepositoryManager.class).getDefaultRepository(); if (repository == null) { throw new ClientException("Cannot get default repository"); } Map<String, Serializable> context = new HashMap<String, Serializable>(); context.put("principal", getSerializablePrincipal(req)); session = repository.open(context); } catch (Exception e) { handleError(res, e); return; } try { // read the search term passed as the 'q' request parameter String keywords = getQueryParamValue(req, "q", " "); // perform the search on the fulltext index and wrap the results as // a DocumentModelList with the 10 first matching results ordered by // modification time String query = String.format(QUERY, keywords); DocumentModelList documents = session.query(query, null, MAX, 0, true); // build the RSS 2.0 response document holding the results DOMDocumentFactory domFactory = new DOMDocumentFactory(); DOMDocument resultDocument = (DOMDocument) domFactory.createDocument(); // rss root tag Element rssElement = resultDocument.addElement(RSS_TAG); rssElement.addAttribute("version", "2.0"); rssElement.addNamespace(OPENSEARCH_NS.getPrefix(), OPENSEARCH_NS.getURI()); rssElement.addNamespace(ATOM_NS.getPrefix(), ATOM_NS.getURI()); // channel with OpenSearch metadata Element channelElement = rssElement.addElement(CHANNEL_TAG); channelElement.addElement(TITLE_TAG).setText("Nuxeo EP OpenSearch channel for " + keywords); channelElement.addElement("link").setText(BaseURL.getBaseURL(getHttpRequest(req)) + "restAPI/opensearch?q=" + URLEncoder.encode(keywords, "UTF-8")); channelElement.addElement(new QName("totalResults", OPENSEARCH_NS)) .setText(Long.toString(documents.totalSize())); channelElement.addElement(new QName("startIndex", OPENSEARCH_NS)).setText("0"); channelElement.addElement(new QName("itemsPerPage", OPENSEARCH_NS)) .setText(Integer.toString(documents.size())); Element queryElement = channelElement.addElement(new QName("Query", OPENSEARCH_NS)); queryElement.addAttribute("role", "request"); queryElement.addAttribute("searchTerms", keywords); queryElement.addAttribute("startPage", Integer.toString(1)); // document items String baseUrl = BaseURL.getBaseURL(getHttpRequest(req)); for (DocumentModel doc : documents) { Element itemElement = channelElement.addElement(ITEM_TAG); Element titleElement = itemElement.addElement(TITLE_TAG); String title = doc.getTitle(); if (title != null) { titleElement.setText(title); } Element descriptionElement = itemElement.addElement(DESCRIPTION_TAG); String description = doc.getProperty("dublincore:description").getValue(String.class); if (description != null) { descriptionElement.setText(description); } Element linkElement = itemElement.addElement("link"); linkElement.setText(baseUrl + DocumentModelFunctions.documentUrl(doc)); } Representation rep = new StringRepresentation(resultDocument.asXML(), MediaType.APPLICATION_XML); rep.setCharacterSet(CharacterSet.UTF_8); res.setEntity(rep); } catch (Exception e) { handleError(res, e); } finally { try { Repository.close(session); } catch (Exception e) { log.error("Repository close failed", e); } } }
From source file:org.nuxeo.ecm.webapp.liveedit.LiveEditBootstrapHelper.java
License:Apache License
/** * Creates the bootstrap file. It is called from the browser's addon. The URL composition tells the case and what to * create. The structure is depicted in the NXP-1881. Rux NXP-1959: add new tag on root level describing the action: * actionEdit, actionNew or actionFromTemplate. * * @return the bootstrap file content/*from w w w .j av a2 s.com*/ */ public void getBootstrap() throws IOException { String currentRepoID = documentManager.getRepositoryName(); CoreSession session = documentManager; CoreSession templateSession = documentManager; try { if (repoID != null && !currentRepoID.equals(repoID)) { session = CoreInstance.openCoreSession(repoID); } if (templateRepoID != null && !currentRepoID.equals(templateRepoID)) { templateSession = CoreInstance.openCoreSession(templateRepoID); } DocumentModel doc = null; DocumentModel templateDoc = null; String filename = null; if (ACTION_EDIT_DOCUMENT.equals(action)) { // fetch the document to edit to get its mimetype and document // type doc = session.getDocument(new IdRef(docRef)); docType = doc.getType(); Blob blob = null; if (blobPropertyName != null) { blob = (Blob) doc.getPropertyValue(blobPropertyName); if (blob == null) { throw new NuxeoException( String.format("could not find blob to edit with property '%s'", blobPropertyName)); } } else { blob = (Blob) doc.getProperty(schema, blobField); if (blob == null) { throw new NuxeoException(String.format( "could not find blob to edit with schema '%s' and field '%s'", schema, blobField)); } } mimetype = blob.getMimeType(); if (filenamePropertyName != null) { filename = (String) doc.getPropertyValue(filenamePropertyName); } else { filename = (String) doc.getProperty(schema, filenameField); } } else if (ACTION_CREATE_DOCUMENT.equals(action)) { // creating a new document all parameters are read from the // request parameters } else if (ACTION_CREATE_DOCUMENT_FROM_TEMPLATE.equals(action)) { // fetch the template blob to get its mimetype templateDoc = templateSession.getDocument(new IdRef(templateDocRef)); Blob blob = (Blob) templateDoc.getProperty(templateSchema, templateBlobField); if (blob == null) { throw new NuxeoException( String.format("could not find template blob with schema '%s' and field '%s'", templateSchema, templateBlobField)); } mimetype = blob.getMimeType(); // leave docType from the request query parameter } else { throw new NuxeoException(String.format( "action '%s' is not a valid LiveEdit action: should be one of '%s', '%s' or '%s'", action, ACTION_CREATE_DOCUMENT, ACTION_CREATE_DOCUMENT_FROM_TEMPLATE, ACTION_EDIT_DOCUMENT)); } FacesContext context = FacesContext.getCurrentInstance(); HttpServletResponse response = (HttpServletResponse) context.getExternalContext().getResponse(); HttpServletRequest request = (HttpServletRequest) context.getExternalContext().getRequest(); Element root = DocumentFactory.getInstance().createElement(liveEditTag); root.addNamespace("", XML_LE_NAMESPACE); // RUX NXP-1959: action id Element actionInfo = root.addElement(actionSelectorTag); actionInfo.setText(action); // Document related informations Element docInfo = root.addElement(documentTag); addTextElement(docInfo, docRefTag, docRef); Element docPathT = docInfo.addElement(docPathTag); Element docTitleT = docInfo.addElement(docTitleTag); if (doc != null) { docPathT.setText(doc.getPathAsString()); docTitleT.setText(doc.getTitle()); } addTextElement(docInfo, docRepositoryTag, repoID); addTextElement(docInfo, docSchemaNameTag, schema); addTextElement(docInfo, docFieldNameTag, blobField); addTextElement(docInfo, docBlobFieldNameTag, blobField); Element docFieldPathT = docInfo.addElement(docfieldPathTag); Element docBlobFieldPathT = docInfo.addElement(docBlobFieldPathTag); if (blobPropertyName != null) { // FIXME AT: NXP-2306: send blobPropertyName correctly (?) docFieldPathT.setText(blobPropertyName); docBlobFieldPathT.setText(blobPropertyName); } else { if (schema != null && blobField != null) { docFieldPathT.setText(schema + ':' + blobField); docBlobFieldPathT.setText(schema + ':' + blobField); } } addTextElement(docInfo, docFilenameFieldNameTag, filenameField); Element docFilenameFieldPathT = docInfo.addElement(docFilenameFieldPathTag); if (filenamePropertyName != null) { docFilenameFieldPathT.setText(filenamePropertyName); } else { if (schema != null && blobField != null) { docFilenameFieldPathT.setText(schema + ':' + filenameField); } } addTextElement(docInfo, docfileNameTag, filename); addTextElement(docInfo, docTypeTag, docType); addTextElement(docInfo, docMimetypeTag, mimetype); addTextElement(docInfo, docFileExtensionTag, getFileExtension(mimetype)); Element docFileAuthorizedExtensions = docInfo.addElement(docFileAuthorizedExtensionsTag); List<String> authorizedExtensions = getFileExtensions(mimetype); if (authorizedExtensions != null) { for (String extension : authorizedExtensions) { addTextElement(docFileAuthorizedExtensions, docFileAuthorizedExtensionTag, extension); } } Element docIsVersionT = docInfo.addElement(docIsVersionTag); Element docIsLockedT = docInfo.addElement(docIsLockedTag); if (ACTION_EDIT_DOCUMENT.equals(action)) { docIsVersionT.setText(Boolean.toString(doc.isVersion())); docIsLockedT.setText(Boolean.toString(doc.isLocked())); } // template information for ACTION_CREATE_DOCUMENT_FROM_TEMPLATE Element templateDocInfo = root.addElement(templateDocumentTag); addTextElement(templateDocInfo, docRefTag, templateDocRef); docPathT = templateDocInfo.addElement(docPathTag); docTitleT = templateDocInfo.addElement(docTitleTag); if (templateDoc != null) { docPathT.setText(templateDoc.getPathAsString()); docTitleT.setText(templateDoc.getTitle()); } addTextElement(templateDocInfo, docRepositoryTag, templateRepoID); addTextElement(templateDocInfo, docSchemaNameTag, templateSchema); addTextElement(templateDocInfo, docFieldNameTag, templateBlobField); addTextElement(templateDocInfo, docBlobFieldNameTag, templateBlobField); docFieldPathT = templateDocInfo.addElement(docfieldPathTag); docBlobFieldPathT = templateDocInfo.addElement(docBlobFieldPathTag); if (templateSchema != null && templateBlobField != null) { docFieldPathT.setText(templateSchema + ":" + templateBlobField); docBlobFieldPathT.setText(templateSchema + ":" + templateBlobField); } addTextElement(templateDocInfo, docMimetypeTag, mimetype); addTextElement(templateDocInfo, docFileExtensionTag, getFileExtension(mimetype)); Element templateFileAuthorizedExtensions = templateDocInfo.addElement(docFileAuthorizedExtensionsTag); if (authorizedExtensions != null) { for (String extension : authorizedExtensions) { addTextElement(templateFileAuthorizedExtensions, docFileAuthorizedExtensionTag, extension); } } // Browser request related informations Element requestInfo = root.addElement(requestInfoTag); Cookie[] cookies = request.getCookies(); Element cookiesT = requestInfo.addElement(requestCookiesTag); for (Cookie cookie : cookies) { Element cookieT = cookiesT.addElement(requestCookieTag); cookieT.addAttribute("name", cookie.getName()); cookieT.setText(cookie.getValue()); } Element headersT = requestInfo.addElement(requestHeadersTag); Enumeration hEnum = request.getHeaderNames(); while (hEnum.hasMoreElements()) { String hName = (String) hEnum.nextElement(); if (!hName.equalsIgnoreCase("cookie")) { Element headerT = headersT.addElement(requestHeaderTag); headerT.addAttribute("name", hName); headerT.setText(request.getHeader(hName)); } } addTextElement(requestInfo, requestBaseURLTag, BaseURL.getBaseURL(request)); // User related informations String username = context.getExternalContext().getUserPrincipal().getName(); Element userInfo = root.addElement(userInfoTag); addTextElement(userInfo, userNameTag, username); addTextElement(userInfo, userPasswordTag, ""); addTextElement(userInfo, userTokenTag, ""); addTextElement(userInfo, userLocaleTag, context.getViewRoot().getLocale().toString()); // Rux NXP-1882: the wsdl locations String baseUrl = BaseURL.getBaseURL(request); Element wsdlLocations = root.addElement(wsdlLocationsTag); Element wsdlAccessWST = wsdlLocations.addElement(wsdlAccessWebServiceTag); wsdlAccessWST.setText(baseUrl + "webservices/nuxeoAccess?wsdl"); Element wsdlEEWST = wsdlLocations.addElement(wsdlLEWebServiceTag); wsdlEEWST.setText(baseUrl + "webservices/nuxeoLEWS?wsdl"); // Server related informations Element serverInfo = root.addElement(serverInfoTag); Element serverVersionT = serverInfo.addElement(serverVersionTag); serverVersionT.setText("5.1"); // TODO: use a buildtime generated // version tag instead // Client related informations Element editId = root.addElement(editIdTag); editId.setText(getEditId(doc, session, username)); // serialize bootstrap XML document in the response Document xmlDoc = DocumentFactory.getInstance().createDocument(); xmlDoc.setRootElement(root); response.setContentType("text/xml; charset=UTF-8"); // use a formatter to make it easier to debug live edit client // implementations OutputFormat format = OutputFormat.createPrettyPrint(); format.setEncoding("UTF-8"); XMLWriter writer = new XMLWriter(response.getOutputStream(), format); writer.write(xmlDoc); response.flushBuffer(); context.responseComplete(); } finally { if (session != null && session != documentManager) { session.close(); } if (templateSession != null && templateSession != documentManager) { templateSession.close(); } } }
From source file:org.onosproject.xmpp.core.ctl.handlers.XmppDecoder.java
License:Apache License
@Override protected void decode(ChannelHandlerContext channelHandlerContext, Object object, List out) throws Exception { if (object instanceof Element) { Element root = (Element) object; try {// ww w.j a va 2 s .c om Packet packet = recognizeAndReturnXmppPacket(root); validate(packet); out.add(packet); } catch (UnsupportedStanzaTypeException e) { throw e; } catch (Exception e) { throw new XmppValidationException(false); } } else if (object instanceof XMLEvent) { XMLEvent event = (XMLEvent) object; if (event.isStartElement()) { final StartElement element = event.asStartElement(); if (element.getName().getLocalPart().equals(XmppConstants.STREAM_QNAME)) { DocumentFactory df = DocumentFactory.getInstance(); QName qname = (element.getName().getPrefix() == null) ? df.createQName(element.getName().getLocalPart(), element.getName().getNamespaceURI()) : df.createQName(element.getName().getLocalPart(), element.getName().getPrefix(), element.getName().getNamespaceURI()); Element newElement = df.createElement(qname); Iterator nsIt = element.getNamespaces(); // add all relevant XML namespaces to Element while (nsIt.hasNext()) { Namespace ns = (Namespace) nsIt.next(); newElement.addNamespace(ns.getPrefix(), ns.getNamespaceURI()); } Iterator attrIt = element.getAttributes(); // add all attributes to Element while (attrIt.hasNext()) { Attribute attr = (Attribute) attrIt.next(); newElement.addAttribute(attr.getName().getLocalPart(), attr.getValue()); } XmppStreamOpen xmppStreamOpen = new XmppStreamOpen(newElement); validator.validateStream(xmppStreamOpen); out.add(xmppStreamOpen); } } else if (event.isEndElement()) { out.add(new XmppStreamClose()); } } }
From source file:org.openbravo.dal.xml.ModelXMLConverter.java
License:Open Source License
/** * Generates the XML Schema representation of the in-memory model. This XML Schema represents the * in- and output of the REST web-services. * /*from w w w.j a v a2 s. co m*/ * @return the Dom4j document containing the XML Schema. */ public Document getSchema() { final Document doc = XMLUtil.getInstance().createDomDocument(); doc.addComment("\n* ***********************************************************************************\n" + "* The contents of this file are subject to the Openbravo Public License" + "* Version 1.1 (the \"License\"), being the Mozilla Public License" + "* Version 1.1 with a permitted attribution clause; you may not use this" + "* file except in compliance with the License. You may obtain a copy of" + "* the License at http://www.openbravo.com/legal/license.html " + "* Software distributed under the License is distributed on an \"AS IS\"" + "* basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the" + "* License for the specific language governing rights and limitations" + "* under the License. " + "* The Original Code is Openbravo ERP. " + "* The Initial Developer of the Original Code is Openbravo SLU" + "* All portions are Copyright (C) 2008-2011 Openbravo SLU" + "* All Rights Reserved. " + "* Contributor(s): ______________________________________." + "* ***********************************************************************************\n"); final Element root = doc.addElement("xs:schema"); root.addNamespace("xs", "http://www.w3.org/2001/XMLSchema"); root.addNamespace("ob", "http://www.openbravo.com"); root.addAttribute("targetNamespace", "http://www.openbravo.com"); final List<String> entityNames = new ArrayList<String>(); for (final Entity e : ModelProvider.getInstance().getModel()) { entityNames.add(e.getName()); } Collections.sort(entityNames); final Element rootElement = root.addElement("xs:element"); rootElement.addAttribute("name", XMLConstants.OB_ROOT_ELEMENT); final Element complexType = rootElement.addElement("xs:complexType"); final Element choiceElement = complexType.addElement("xs:choice"); choiceElement.addAttribute("minOccurs", "0"); choiceElement.addAttribute("maxOccurs", "unbounded"); complexType.addElement("xs:attribute").addAttribute("name", XMLConstants.DATE_TIME_ATTRIBUTE) .addAttribute("type", "xs:string").addAttribute("use", "optional"); complexType.addElement("xs:attribute").addAttribute("name", XMLConstants.OB_VERSION_ATTRIBUTE) .addAttribute("type", "xs:string").addAttribute("use", "optional"); complexType.addElement("xs:attribute").addAttribute("name", XMLConstants.OB_REVISION_ATTRIBUTE) .addAttribute("type", "xs:string").addAttribute("use", "optional"); for (final String entityName : entityNames) { final Element entityElement = choiceElement.addElement("xs:element"); entityElement.addAttribute("name", entityName); entityElement.addAttribute("type", "ob:" + entityName + "Type"); } for (final String entityName : entityNames) { final Element typeElement = root.addElement("xs:complexType"); typeElement.addAttribute("name", entityName + "Type"); final Element typeSequenceElement = typeElement.addElement("xs:sequence"); typeSequenceElement.addAttribute("minOccurs", "0"); addPropertyElements(typeSequenceElement, ModelProvider.getInstance().getEntity(entityName)); typeElement.addElement("xs:attribute").addAttribute("name", XMLConstants.ID_ATTRIBUTE) .addAttribute("type", "xs:string").addAttribute("use", "optional"); typeElement.addElement("xs:attribute").addAttribute("name", XMLConstants.IDENTIFIER_ATTRIBUTE) .addAttribute("type", "xs:string").addAttribute("use", "optional"); typeElement.addElement("xs:attribute").addAttribute("name", XMLConstants.REFERENCE_ATTRIBUTE) .addAttribute("type", "xs:boolean").addAttribute("use", "optional"); typeElement.addElement("xs:anyAttribute"); } addSimpleTypeDeclarations(root); addReferenceType(root); addErrorSchema(root); addResultSchema(root); return doc; }