List of usage examples for javax.xml.stream XMLStreamWriter writeEndElement
public void writeEndElement() throws XMLStreamException;
From source file:jp.zippyzip.impl.GeneratorServiceImpl.java
public void storeX0401Zip() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); long timestamp = getLzhDao().getZipInfo().getTimestamp().getTime(); ZipOutputStream out = new ZipOutputStream(baos); Collection<Pref> prefs = getPrefs(); ZipEntry tsv = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0401_utf8.txt"); ZipEntry csv = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0401_sjis.csv"); ZipEntry json = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0401_utf8.json"); ZipEntry xml = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0401_utf8.xml"); tsv.setTime(timestamp);/*from w ww .j a v a 2 s . c o m*/ csv.setTime(timestamp); json.setTime(timestamp); xml.setTime(timestamp); try { out.putNextEntry(tsv); for (Pref pref : prefs) { out.write(new String(pref.getCode() + "\t" + pref.getName() + "\t" + pref.getYomi() + CRLF) .getBytes("UTF-8")); } out.closeEntry(); out.putNextEntry(csv); for (Pref pref : prefs) { out.write(new String(pref.getCode() + "," + pref.getName() + "," + pref.getYomi() + CRLF) .getBytes("MS932")); } out.closeEntry(); out.putNextEntry(json); OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8"); JSONWriter jwriter = new JSONWriter(writer); jwriter.array(); for (Pref pref : prefs) { jwriter.object().key("code").value(pref.getCode()).key("name").value(pref.getName()).key("yomi") .value(pref.getYomi()).endObject(); } jwriter.endArray(); writer.flush(); out.closeEntry(); out.putNextEntry(xml); XMLStreamWriter xwriter = XMLOutputFactory.newInstance() .createXMLStreamWriter(new OutputStreamWriter(out, "UTF-8")); xwriter.writeStartDocument("UTF-8", "1.0"); xwriter.writeStartElement("x0401s"); for (Pref pref : prefs) { xwriter.writeStartElement("x0401"); xwriter.writeAttribute("code", pref.getCode()); xwriter.writeAttribute("name", pref.getName()); xwriter.writeAttribute("yomi", pref.getYomi()); xwriter.writeEndElement(); } xwriter.writeEndElement(); xwriter.writeEndDocument(); xwriter.flush(); out.closeEntry(); out.finish(); baos.flush(); getRawDao().store(baos.toByteArray(), "x0401.zip"); log.info("prefs: " + prefs.size()); } catch (JSONException e) { log.log(Level.WARNING, "", e); } catch (XMLStreamException e) { log.log(Level.WARNING, "", e); } catch (FactoryConfigurationError e) { log.log(Level.WARNING, "", e); } catch (IOException e) { log.log(Level.WARNING, "", e); } }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.SchemaGraph2XMI.java
/** * Creates the root <code>XMI</code> tag of the whole document. It calls * {@link SchemaGraph2XMI#createModelElement(XMLStreamWriter, SchemaGraph)} * to create its content.//from w w w . j av a 2s . c om * * @param writer * {@link XMLStreamWriter} of the current XMI file * @param schemaGraph * {@link SchemaGraph} to be converted into an XMI * @throws XMLStreamException */ private void createRootElement(XMLStreamWriter writer, SchemaGraph schemaGraph) throws XMLStreamException { // start root element writer.writeStartElement(XMIConstants4SchemaGraph2XMI.NAMESPACE_PREFIX_XMI, XMIConstants4SchemaGraph2XMI.XMI_TAG_XMI, XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_VERSION, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_VERSION_VALUE); writer.setPrefix(XMIConstants4SchemaGraph2XMI.NAMESPACE_PREFIX_XSI, XMIConstants4SchemaGraph2XMI.NAMESPACE_XSI); writer.setPrefix(XMIConstants4SchemaGraph2XMI.NAMESPACE_PREFIX_EECORE, XMIConstants4SchemaGraph2XMI.NAMESPACE_EECORE); writer.setPrefix(XMIConstants4SchemaGraph2XMI.NAMESPACE_PREFIX_ECORE, XMIConstants4SchemaGraph2XMI.NAMESPACE_ECORE); writer.setPrefix(XMIConstants4SchemaGraph2XMI.NAMESPACE_PREFIX_UML, XMIConstants4SchemaGraph2XMI.NAMESPACE_UML); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XSI, XMIConstants4SchemaGraph2XMI.XSI_ATTRIBUTE_SCHEMALOCATION, XMIConstants4SchemaGraph2XMI.SCHEMALOCATION); // create model element createModelElement(writer, schemaGraph); // close root element writer.writeEndElement(); }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private void handleMultiBlobRemove(HttpServletResponse response, InputStream is, BlobStore blobStore, String containerName) throws IOException { DeleteMultipleObjectsRequest dmor = new XmlMapper().readValue(is, DeleteMultipleObjectsRequest.class); Collection<String> blobNames = new ArrayList<>(); for (DeleteMultipleObjectsRequest.S3Object s3Object : dmor.objects) { blobNames.add(s3Object.key); }// w w w. java2 s.c o m blobStore.removeBlobs(containerName, blobNames); try (Writer writer = response.getWriter()) { XMLStreamWriter xml = xmlOutputFactory.createXMLStreamWriter(writer); xml.writeStartDocument(); xml.writeStartElement("DeleteResult"); xml.writeDefaultNamespace(AWS_XMLNS); if (!dmor.quiet) { for (String blobName : blobNames) { xml.writeStartElement("Deleted"); writeSimpleElement(xml, "Key", blobName); xml.writeEndElement(); } } // TODO: emit error stanza xml.writeEndElement(); xml.flush(); } catch (XMLStreamException xse) { throw new IOException(xse); } }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
private void handleCopyBlob(HttpServletRequest request, HttpServletResponse response, InputStream is, BlobStore blobStore, String destContainerName, String destBlobName) throws IOException, S3Exception { String copySourceHeader = request.getHeader("x-amz-copy-source"); copySourceHeader = URLDecoder.decode(copySourceHeader, "UTF-8"); if (copySourceHeader.startsWith("/")) { // Some clients like boto do not include the leading slash copySourceHeader = copySourceHeader.substring(1); }//w w w . j a v a 2 s .c o m String[] path = copySourceHeader.split("/", 2); if (path.length != 2) { throw new S3Exception(S3ErrorCode.INVALID_REQUEST); } String sourceContainerName = path[0]; String sourceBlobName = path[1]; boolean replaceMetadata = "REPLACE".equalsIgnoreCase(request.getHeader("x-amz-metadata-directive")); if (sourceContainerName.equals(destContainerName) && sourceBlobName.equals(destBlobName) && !replaceMetadata) { throw new S3Exception(S3ErrorCode.INVALID_REQUEST); } CopyOptions.Builder options = CopyOptions.builder(); String ifMatch = request.getHeader("x-amz-copy-source-if-match"); if (ifMatch != null) { options.ifMatch(ifMatch); } String ifNoneMatch = request.getHeader("x-amz-copy-source-if-none-match"); if (ifNoneMatch != null) { options.ifNoneMatch(ifNoneMatch); } long ifModifiedSince = request.getDateHeader("x-amz-copy-source-if-modified-since"); if (ifModifiedSince != -1) { options.ifModifiedSince(new Date(ifModifiedSince)); } long ifUnmodifiedSince = request.getDateHeader("x-amz-copy-source-if-unmodified-since"); if (ifUnmodifiedSince != -1) { options.ifUnmodifiedSince(new Date(ifUnmodifiedSince)); } if (replaceMetadata) { ContentMetadataBuilder contentMetadata = ContentMetadataBuilder.create(); ImmutableMap.Builder<String, String> userMetadata = ImmutableMap.builder(); for (String headerName : Collections.list(request.getHeaderNames())) { String headerValue = Strings.nullToEmpty(request.getHeader(headerName)); if (headerName.equalsIgnoreCase(HttpHeaders.CACHE_CONTROL)) { contentMetadata.cacheControl(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_DISPOSITION)) { contentMetadata.contentDisposition(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_ENCODING)) { contentMetadata.contentEncoding(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_LANGUAGE)) { contentMetadata.contentLanguage(headerValue); } else if (headerName.equalsIgnoreCase(HttpHeaders.CONTENT_TYPE)) { contentMetadata.contentType(headerValue); } else if (startsWithIgnoreCase(headerName, USER_METADATA_PREFIX)) { userMetadata.put(headerName.substring(USER_METADATA_PREFIX.length()), headerValue); } // TODO: Expires } options.contentMetadata(contentMetadata.build()); options.userMetadata(userMetadata.build()); } String eTag; try { eTag = blobStore.copyBlob(sourceContainerName, sourceBlobName, destContainerName, destBlobName, options.build()); } catch (KeyNotFoundException knfe) { throw new S3Exception(S3ErrorCode.NO_SUCH_KEY, knfe); } // TODO: jclouds should include this in CopyOptions String cannedAcl = request.getHeader("x-amz-acl"); if (cannedAcl != null && !cannedAcl.equalsIgnoreCase("private")) { handleSetBlobAcl(request, response, is, blobStore, destContainerName, destBlobName); } BlobMetadata blobMetadata = blobStore.blobMetadata(destContainerName, destBlobName); try (Writer writer = response.getWriter()) { XMLStreamWriter xml = xmlOutputFactory.createXMLStreamWriter(writer); xml.writeStartDocument(); xml.writeStartElement("CopyObjectResult"); xml.writeDefaultNamespace(AWS_XMLNS); writeSimpleElement(xml, "LastModified", formatDate(blobMetadata.getLastModified())); writeSimpleElement(xml, "ETag", maybeQuoteETag(eTag)); xml.writeEndElement(); xml.flush(); } catch (XMLStreamException xse) { throw new IOException(xse); } }
From source file:ca.uhn.fhir.parser.XmlParser.java
private void encodeXhtml(XhtmlDt theDt, XMLStreamWriter theEventWriter) throws XMLStreamException { if (theDt == null || theDt.getValue() == null) { return;/*from w ww . j a v a2s. c om*/ } boolean firstElement = true; for (XMLEvent event : theDt.getValue()) { switch (event.getEventType()) { case XMLStreamConstants.ATTRIBUTE: Attribute attr = (Attribute) event; if (isBlank(attr.getName().getPrefix())) { if (isBlank(attr.getName().getNamespaceURI())) { theEventWriter.writeAttribute(attr.getName().getLocalPart(), attr.getValue()); } else { theEventWriter.writeAttribute(attr.getName().getNamespaceURI(), attr.getName().getLocalPart(), attr.getValue()); } } else { theEventWriter.writeAttribute(attr.getName().getPrefix(), attr.getName().getNamespaceURI(), attr.getName().getLocalPart(), attr.getValue()); } break; case XMLStreamConstants.CDATA: theEventWriter.writeCData(((Characters) event).getData()); break; case XMLStreamConstants.CHARACTERS: case XMLStreamConstants.SPACE: String data = ((Characters) event).getData(); theEventWriter.writeCharacters(data); break; case XMLStreamConstants.COMMENT: theEventWriter.writeComment(((Comment) event).getText()); break; case XMLStreamConstants.END_ELEMENT: theEventWriter.writeEndElement(); break; case XMLStreamConstants.ENTITY_REFERENCE: EntityReference er = (EntityReference) event; theEventWriter.writeEntityRef(er.getName()); break; case XMLStreamConstants.NAMESPACE: Namespace ns = (Namespace) event; theEventWriter.writeNamespace(ns.getPrefix(), ns.getNamespaceURI()); break; case XMLStreamConstants.START_ELEMENT: StartElement se = event.asStartElement(); if (firstElement) { if (StringUtils.isBlank(se.getName().getPrefix())) { String namespaceURI = se.getName().getNamespaceURI(); if (StringUtils.isBlank(namespaceURI)) { namespaceURI = "http://www.w3.org/1999/xhtml"; } theEventWriter.writeStartElement(se.getName().getLocalPart()); theEventWriter.writeDefaultNamespace(namespaceURI); } else { String prefix = se.getName().getPrefix(); String namespaceURI = se.getName().getNamespaceURI(); theEventWriter.writeStartElement(prefix, se.getName().getLocalPart(), namespaceURI); theEventWriter.writeNamespace(prefix, namespaceURI); } firstElement = false; } else { if (isBlank(se.getName().getPrefix())) { if (isBlank(se.getName().getNamespaceURI())) { theEventWriter.writeStartElement(se.getName().getLocalPart()); } else { if (StringUtils.isBlank(se.getName().getPrefix())) { theEventWriter.writeStartElement(se.getName().getLocalPart()); // theEventWriter.writeDefaultNamespace(se.getName().getNamespaceURI()); } else { theEventWriter.writeStartElement(se.getName().getNamespaceURI(), se.getName().getLocalPart()); } } } else { theEventWriter.writeStartElement(se.getName().getPrefix(), se.getName().getLocalPart(), se.getName().getNamespaceURI()); } for (Iterator<?> attrIter = se.getAttributes(); attrIter.hasNext();) { Attribute next = (Attribute) attrIter.next(); theEventWriter.writeAttribute(next.getName().getLocalPart(), next.getValue()); } } break; case XMLStreamConstants.DTD: case XMLStreamConstants.END_DOCUMENT: case XMLStreamConstants.ENTITY_DECLARATION: case XMLStreamConstants.NOTATION_DECLARATION: case XMLStreamConstants.PROCESSING_INSTRUCTION: case XMLStreamConstants.START_DOCUMENT: break; } } }
From source file:com.liferay.portal.util.LocalizationImpl.java
public String removeLocalization(String xml, String key, String requestedLanguageId, boolean cdata, boolean localized) { if (Validator.isNull(xml)) { return StringPool.BLANK; }//from w w w.jav a2s. com xml = _sanitizeXML(xml); String systemDefaultLanguageId = LocaleUtil.toLanguageId(LocaleUtil.getDefault()); XMLStreamReader xmlStreamReader = null; XMLStreamWriter xmlStreamWriter = null; ClassLoader portalClassLoader = PortalClassLoaderUtil.getClassLoader(); Thread currentThread = Thread.currentThread(); ClassLoader contextClassLoader = currentThread.getContextClassLoader(); try { if (contextClassLoader != portalClassLoader) { currentThread.setContextClassLoader(portalClassLoader); } XMLInputFactory xmlInputFactory = XMLInputFactory.newInstance(); xmlStreamReader = xmlInputFactory.createXMLStreamReader(new UnsyncStringReader(xml)); String availableLocales = StringPool.BLANK; String defaultLanguageId = StringPool.BLANK; // Read root node if (xmlStreamReader.hasNext()) { xmlStreamReader.nextTag(); availableLocales = xmlStreamReader.getAttributeValue(null, _AVAILABLE_LOCALES); defaultLanguageId = xmlStreamReader.getAttributeValue(null, _DEFAULT_LOCALE); if (Validator.isNull(defaultLanguageId)) { defaultLanguageId = systemDefaultLanguageId; } } if ((availableLocales != null) && (availableLocales.indexOf(requestedLanguageId) != -1)) { availableLocales = StringUtil.remove(availableLocales, requestedLanguageId, StringPool.COMMA); UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter(); XMLOutputFactory xmlOutputFactory = XMLOutputFactory.newInstance(); xmlStreamWriter = xmlOutputFactory.createXMLStreamWriter(unsyncStringWriter); xmlStreamWriter.writeStartDocument(); xmlStreamWriter.writeStartElement(_ROOT); if (localized) { xmlStreamWriter.writeAttribute(_AVAILABLE_LOCALES, availableLocales); xmlStreamWriter.writeAttribute(_DEFAULT_LOCALE, defaultLanguageId); } _copyNonExempt(xmlStreamReader, xmlStreamWriter, requestedLanguageId, defaultLanguageId, cdata); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeEndDocument(); xmlStreamWriter.close(); xmlStreamWriter = null; xml = unsyncStringWriter.toString(); } } catch (Exception e) { if (_log.isWarnEnabled()) { _log.warn(e, e); } } finally { if (contextClassLoader != portalClassLoader) { currentThread.setContextClassLoader(contextClassLoader); } if (xmlStreamReader != null) { try { xmlStreamReader.close(); } catch (Exception e) { } } if (xmlStreamWriter != null) { try { xmlStreamWriter.close(); } catch (Exception e) { } } } return xml; }
From source file:org.gaul.s3proxy.S3ProxyHandler.java
protected final void sendSimpleErrorResponse(HttpServletRequest request, HttpServletResponse response, S3ErrorCode code, String message, Map<String, String> elements) throws IOException { logger.debug("{} {}", code, elements); response.setStatus(code.getHttpStatusCode()); if (request.getMethod().equals("HEAD")) { // The HEAD method is identical to GET except that the server MUST // NOT return a message-body in the response. return;/*from w ww .java 2s . c om*/ } try (Writer writer = response.getWriter()) { XMLStreamWriter xml = xmlOutputFactory.createXMLStreamWriter(writer); xml.writeStartDocument(); xml.writeStartElement("Error"); writeSimpleElement(xml, "Code", code.getErrorCode()); writeSimpleElement(xml, "Message", message); for (Map.Entry<String, String> entry : elements.entrySet()) { writeSimpleElement(xml, entry.getKey(), entry.getValue()); } writeSimpleElement(xml, "RequestId", FAKE_REQUEST_ID); xml.writeEndElement(); xml.flush(); } catch (XMLStreamException xse) { throw new IOException(xse); } }
From source file:jp.zippyzip.impl.GeneratorServiceImpl.java
public void storeX0402Zip() { ByteArrayOutputStream baos = new ByteArrayOutputStream(); long timestamp = getLzhDao().getZipInfo().getTimestamp().getTime(); ZipOutputStream out = new ZipOutputStream(baos); Collection<City> cities = getCities(); ZipEntry tsv = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0402_utf8.txt"); ZipEntry csv = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0402_sjis.csv"); ZipEntry json = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0402_utf8.json"); ZipEntry xml = new ZipEntry(FILENAME_DATE_FORMAT.format(new Date(timestamp)) + "_x0402_utf8.xml"); tsv.setTime(timestamp);//from w ww . j a va 2s .c o m csv.setTime(timestamp); json.setTime(timestamp); xml.setTime(timestamp); try { out.putNextEntry(tsv); for (City city : cities) { out.write(new String(city.getCode() + "\t" + city.getName() + "\t" + city.getYomi() + "\t" + ((city.getExpiration().getTime() < new Date().getTime()) ? "" : "") + CRLF) .getBytes("UTF-8")); } out.closeEntry(); out.putNextEntry(csv); for (City city : cities) { out.write(new String(city.getCode() + "," + city.getName() + "," + city.getYomi() + "," + ((city.getExpiration().getTime() < new Date().getTime()) ? "" : "") + CRLF) .getBytes("MS932")); } out.closeEntry(); out.putNextEntry(json); OutputStreamWriter writer = new OutputStreamWriter(out, "UTF-8"); JSONWriter jwriter = new JSONWriter(writer); jwriter.array(); for (City city : cities) { jwriter.object().key("code").value(city.getCode()).key("name").value(city.getName()).key("yomi") .value(city.getYomi()).key("expired") .value((city.getExpiration().getTime() < new Date().getTime()) ? "true" : "false") .endObject(); } jwriter.endArray(); writer.flush(); out.closeEntry(); out.putNextEntry(xml); XMLStreamWriter xwriter = XMLOutputFactory.newInstance() .createXMLStreamWriter(new OutputStreamWriter(out, "UTF-8")); xwriter.writeStartDocument("UTF-8", "1.0"); xwriter.writeStartElement("x0402s"); for (City city : cities) { xwriter.writeStartElement("x0402"); xwriter.writeAttribute("code", city.getCode()); xwriter.writeAttribute("name", city.getName()); xwriter.writeAttribute("yomi", city.getYomi()); xwriter.writeAttribute("expired", (city.getExpiration().getTime() < new Date().getTime()) ? "true" : "false"); xwriter.writeEndElement(); } xwriter.writeEndElement(); xwriter.writeEndDocument(); xwriter.flush(); out.closeEntry(); out.finish(); baos.flush(); getRawDao().store(baos.toByteArray(), "x0402.zip"); log.info("cities: " + cities.size()); } catch (JSONException e) { log.log(Level.WARNING, "", e); } catch (XMLStreamException e) { log.log(Level.WARNING, "", e); } catch (FactoryConfigurationError e) { log.log(Level.WARNING, "", e); } catch (IOException e) { log.log(Level.WARNING, "", e); } }
From source file:net.solarnetwork.util.JavaBeanXmlSerializer.java
private void writeElement(String name, Map<?, ?> props, XMLStreamWriter out, boolean close) throws XMLStreamException { out.writeStartElement(name);/* w w w .j av a 2s . c om*/ Map<String, Object> nested = null; if (props != null) { for (Map.Entry<?, ?> me : props.entrySet()) { String key = me.getKey().toString(); Object val = me.getValue(); if (propertySerializerRegistrar != null) { val = propertySerializerRegistrar.serializeProperty(name, val.getClass(), props, val); } if (val instanceof Date) { SimpleDateFormat sdf = SDF.get(); // SimpleDateFormat has no way to create xs:dateTime with tz, // so use trick here to insert required colon for non GMT dates Date date = (Date) val; StringBuilder buf = new StringBuilder(sdf.format(date)); if (buf.charAt(buf.length() - 1) != 'Z') { buf.insert(buf.length() - 2, ':'); } val = buf.toString(); } else if (val instanceof Collection) { if (nested == null) { nested = new LinkedHashMap<String, Object>(5); } nested.put(key, val); val = null; } else if (val instanceof Map<?, ?>) { if (nested == null) { nested = new LinkedHashMap<String, Object>(5); } nested.put(key, val); val = null; } else if (classNamesAllowedForNesting != null && !(val instanceof Enum<?>)) { for (String prefix : classNamesAllowedForNesting) { if (val.getClass().getName().startsWith(prefix)) { if (nested == null) { nested = new LinkedHashMap<String, Object>(5); } nested.put(key, val); val = null; break; } } } if (val != null) { String attVal = val.toString(); out.writeAttribute(key, attVal); } } } if (nested != null) { for (Map.Entry<String, Object> me : nested.entrySet()) { outputObject(me.getValue(), me.getKey(), out); } if (close) { out.writeEndElement(); } } }
From source file:de.uni_koblenz.jgralab.utilities.rsa2tg.SchemaGraph2XMI.java
/** * Defines all attributes of type {@link DoubleDomain}, {@link LongDomain}, * {@link MapDomain} or {@link CollectionDomain} which are used in the * {@link SchemaGraph} i.e. contained in * {@link SchemaGraph2XMI#typesToBeDeclaredAtTheEnd}. These definitions are * created in a new UML package, called <code>PrimitiveTypes</code>. This is * necessary because those {@link Domain}s are not UML primitive types and * are not represented by an own <code>packagedElement</code> in the XMI * file./* ww w .java2s .c o m*/ * * @param writer * {@link XMLStreamWriter} of the current XMI file * @throws XMLStreamException */ private void createTypes(XMLStreamWriter writer) throws XMLStreamException { // start packagedElement writer.writeStartElement(XMIConstants4SchemaGraph2XMI.TAG_PACKAGEDELEMENT); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, XMIConstants4SchemaGraph2XMI.PACKAGEDELEMENT_TYPE_VALUE_PACKAGE); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_ID, XMIConstants4SchemaGraph2XMI.PACKAGE_PRIMITIVETYPES_NAME); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.ATTRIBUTE_NAME, XMIConstants4SchemaGraph2XMI.PACKAGE_PRIMITIVETYPES_NAME); // create entries for domains, which are not defined for (Domain domain : typesToBeDeclaredAtTheEnd) { writer.writeEmptyElement(XMIConstants4SchemaGraph2XMI.TAG_PACKAGEDELEMENT); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_TYPE, XMIConstants4SchemaGraph2XMI.TYPE_VALUE_PRIMITIVETYPE); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.NAMESPACE_XMI, XMIConstants4SchemaGraph2XMI.XMI_ATTRIBUTE_ID, domain.get_qualifiedName().replaceAll("\\s", "").replaceAll("<", "_").replaceAll(">", "_")); writer.writeAttribute(XMIConstants4SchemaGraph2XMI.ATTRIBUTE_NAME, extractSimpleName(domain.get_qualifiedName())); } // end packagedElement writer.writeEndElement(); }