/** * Appends references, e.g., to the OData Core Vocabulary, as defined in the OData specification * and mentioned in its Common Schema Definition Language (CSDL) document. */ private void appendReference(final XMLStreamWriter writer) throws XMLStreamException { for (final EdmxReference reference : serviceMetadata.getReferences()) { writer.writeStartElement(PREFIX_EDMX, REFERENCE, NS_EDMX); writer.writeAttribute(URI, reference.getUri().toASCIIString()); List<EdmxReferenceInclude> includes = reference.getIncludes(); for (EdmxReferenceInclude include : includes) { writer.writeStartElement(PREFIX_EDMX, INCLUDE, NS_EDMX); writer.writeAttribute(XML_NAMESPACE, include.getNamespace()); if (include.getAlias() != null) { // Reference Aliases are ignored for now since they are not V2 compatible writer.writeAttribute(XML_ALIAS, include.getAlias()); } writer.writeEndElement(); } List<EdmxReferenceIncludeAnnotation> includeAnnotations = reference.getIncludeAnnotations(); for (EdmxReferenceIncludeAnnotation includeAnnotation : includeAnnotations) { writer.writeStartElement(PREFIX_EDMX, INCLUDE_ANNOTATIONS, NS_EDMX); writer.writeAttribute(XML_TERM_NAMESPACE, includeAnnotation.getTermNamespace()); if (includeAnnotation.getQualifier() != null) { writer.writeAttribute(XML_QUALIFIER, includeAnnotation.getQualifier()); } if (includeAnnotation.getTargetNamespace() != null) { writer.writeAttribute(XML_TARGET_NAMESPACE, includeAnnotation.getTargetNamespace()); } writer.writeEndElement(); } writer.writeEndElement(); } }
public static void doXmlOutput(boolean useRepairing) throws XMLStreamException { StringWriter buffer = new StringWriter(); XMLOutputFactory outputFactory = XMLOutputFactory.newInstance(); if (useRepairing) { outputFactory.setProperty("javax.xml.stream.isRepairingNamespaces", Boolean.TRUE); } XMLStreamWriter out = outputFactory.createXMLStreamWriter(buffer); out.writeStartDocument(); out.writeStartElement("env", "Envelope", SOAP12); out.writeNamespace("env", SOAP12); out.writeNamespace("test", "http://someTestUri"); out.writeStartElement("env", "Body", SOAP12); out.writeStartElement("test"); out.writeAttribute("foo", "bar"); out.writeEndElement(); out.writeStartElement("test"); out.writeAttribute("foo", "bar"); out.writeCharacters(""); out.writeEndElement(); out.writeStartElement("test"); out.writeAttribute("foo", "bar"); out.writeCharacters(" "); out.writeEndElement(); out.writeEndElement(); out.writeEndElement(); out.writeEndDocument(); out.close(); System.out.println("Created " + (useRepairing ? "" : "not") + " using repairing :-"); System.out.println(buffer); }
/** Writes an Atom collection. */ public void writeCollection(String href, String collectionType, String text, String... accept) throws XMLStreamException { XMLStreamWriter xsw = getWriter(); xsw.writeStartElement(XMLConstants.PREFIX_APP, "collection", XMLConstants.NAMESPACE_APP); xsw.writeAttribute("href", href); if (collectionType != null) { XMLUtils.write( xsw, XMLConstants.PREFIX_RESTATOM, XMLConstants.NAMESPACE_RESTATOM, "collectionType", collectionType); } xsw.writeStartElement(XMLConstants.PREFIX_ATOM, "title", XMLConstants.NAMESPACE_ATOM); xsw.writeAttribute("type", "text"); xsw.writeCharacters(text); xsw.writeEndElement(); for (String ct : accept) { XMLUtils.write(xsw, XMLConstants.PREFIX_APP, XMLConstants.NAMESPACE_APP, "accept", ct); } xsw.writeEndElement(); }
public void run() { try { FileOutputStream fos = new FileOutputStream("" + no); XMLStreamWriter w = getWriter(fos); // System.out.println("Writer="+w+" Thread="+Thread.currentThread()); w.writeStartDocument(); w.writeStartElement("hello"); for (int j = 0; j < 50; j++) { w.writeStartElement("a" + j); w.writeEndElement(); } w.writeEndElement(); w.writeEndDocument(); w.close(); fos.close(); FileInputStream fis = new FileInputStream("" + no); XMLStreamReader r = getReader(fis); while (r.hasNext()) { r.next(); } r.close(); fis.close(); } catch (Exception e) { Assert.fail(e.getMessage()); } }
private void writeAttribution(final XMLStreamWriter writer, final Attribution attribution) throws XMLStreamException { if (attribution != null) { writer.writeStartElement("Attribution"); if (attribution.getTitle() != null) { writer.writeStartElement("Title"); writer.writeCharacters(attribution.getTitle()); writer.writeEndElement(); } writeOnlineResource(writer, attribution.getUrl()); if (attribution.getLogoUrl() != null) { final LogoUrl logoUrl = attribution.getLogoUrl(); writer.writeStartElement("LogoURL"); if (logoUrl.getWidth() != null) { writer.writeAttribute("width", "" + logoUrl.getWidth()); } if (logoUrl.getHeight() != null) { writer.writeAttribute("height", "" + logoUrl.getHeight()); } if (logoUrl.getFormat() != null) { writer.writeStartElement("Format"); writer.writeCharacters(logoUrl.getFormat()); writer.writeEndElement(); } writeOnlineResource(writer, logoUrl.getUrl()); writer.writeEndElement(); } writer.writeEndElement(); } }
private void writeConnections() throws XMLStreamException { out.writeStartElement("connection-list"); for (int i = 0; i < cmap.getConceptCount(); i++) { for (int j = 0; j < cmap.getConceptCount(); j++) { if (cmap.isAnyLinkExisting(cmap.getConcept(i), cmap.getConcept(j))) { boolean directed = cmap.isLinkedDirectedStartToEnd(i, j); out.writeStartElement("connection"); out.writeAttribute("id", "con" + String.valueOf(i) + String.valueOf(j) + "f"); out.writeAttribute("from-id", "c" + i); out.writeAttribute("to-id", "l" + String.valueOf(i) + String.valueOf(j)); if (!directed) out.writeAttribute("isBidirectional", "true"); out.writeEndElement(); out.writeStartElement("connection"); out.writeAttribute("id", "con" + String.valueOf(i) + String.valueOf(j) + "t"); out.writeAttribute("from-id", "l" + String.valueOf(i) + String.valueOf(j)); out.writeAttribute("to-id", "c" + j); if (!directed) out.writeAttribute("isBidirectional", "true"); out.writeEndElement(); } } } out.writeEndElement(); }
protected void writeTimerDefinition( Event parentEvent, TimerEventDefinition timerDefinition, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_EVENT_TIMERDEFINITION); boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(timerDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement(); } if (StringUtils.isNotEmpty(timerDefinition.getTimeDate())) { xtw.writeStartElement(ATTRIBUTE_TIMER_DATE); xtw.writeCharacters(timerDefinition.getTimeDate()); xtw.writeEndElement(); } else if (StringUtils.isNotEmpty(timerDefinition.getTimeCycle())) { xtw.writeStartElement(ATTRIBUTE_TIMER_CYCLE); xtw.writeCharacters(timerDefinition.getTimeCycle()); xtw.writeEndElement(); } else if (StringUtils.isNotEmpty(timerDefinition.getTimeDuration())) { xtw.writeStartElement(ATTRIBUTE_TIMER_DURATION); xtw.writeCharacters(timerDefinition.getTimeDuration()); xtw.writeEndElement(); } xtw.writeEndElement(); }
private void writeTimeInterval(XMLStreamWriter xmlWriter, TimeInterval timeInterval) throws Exception { List<Interval<Double[]>> intervals = timeInterval.getIntervals(visibleInterval.getLow(), visibleInterval.getHigh()); if (intervals.size() > 1) { xmlWriter.writeStartElement(SLICES); for (Interval<Double[]> interval : intervals) { xmlWriter.writeStartElement(SLICE); if (!Double.isInfinite(interval.getLow())) { String intervalLow = formatTime(interval.getLow()); xmlWriter.writeAttribute(interval.isLowExcluded() ? START_OPEN : START, intervalLow); } if (!Double.isInfinite(interval.getHigh())) { String intervalHigh = formatTime(interval.getHigh()); xmlWriter.writeAttribute(interval.isHighExcluded() ? END_OPEN : END, intervalHigh); } xmlWriter.writeEndElement(); } xmlWriter.writeEndElement(); } else if (intervals.size() == 1) { Interval<Double[]> interval = intervals.get(0); if (!Double.isInfinite(interval.getLow())) { String intervalLow = formatTime(interval.getLow()); xmlWriter.writeAttribute(interval.isLowExcluded() ? START_OPEN : START, intervalLow); } if (!Double.isInfinite(interval.getHigh())) { String intervalHigh = formatTime(interval.getHigh()); xmlWriter.writeAttribute(interval.isHighExcluded() ? END_OPEN : END, intervalHigh); } } }
/** * Writes the contents of the given node into the <code>writer</code>. * * @param writer the writer * @param node the current node * @param utterance ... * @throws XMLStreamException error writing to the stream */ private void writeBMLNode(final XMLStreamWriter writer, final Node node, final String utterance) throws XMLStreamException { if (node instanceof Text) { final Text text = (Text) node; final String content = text.getTextContent(); writer.writeCharacters(content); return; } final String tag = node.getNodeName(); writer.writeStartElement(tag); final NamedNodeMap attributes = node.getAttributes(); if (attributes != null) { for (int k = 0; k < attributes.getLength(); k++) { final Node attribute = attributes.item(k); final String name = attribute.getNodeName(); final String value = attribute.getNodeValue(); writer.writeAttribute(name, value); } } final NodeList children = node.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node child = children.item(i); writeBMLNode(writer, child, utterance); } // add text-tag for bml-speech if (tag.contains("speech")) { writer.writeStartElement("text"); writer.writeCharacters(utterance); writer.writeEndElement(); } writer.writeEndElement(); }
public void close() { if (closed) { return; } closed = true; // finish off anything try { xmlw.writeEndElement(); // msRun element // declare the index does not exist xmlw.writeEmptyElement("indexOffset"); xmlw.writeAttribute("xsi:nil", "1"); xmlw.writeEndElement(); // mzXML element // close out the xml writer xmlw.flush(); xmlw.close(); } catch (XMLStreamException e) { throw new RuntimeException("Can't write all of XML!", e); } finally { super.close(); } }
public void marshall(XMLStreamWriter wrt, UserDetails value) throws Exception { // write out the userdetails element.. wrt.writeStartElement("userdetails"); if (value != null) { // marshall the token using the XMLTokenMarshaller.. Token token = value.getToken(); XMLTokenMarshaller mar = new XMLTokenMarshaller(); mar.marshall(wrt, token); // write each of the roles.. String[] values = value.getRoles(); for (int i = 0; (values != null && i < values.length); i++) { String role = values[i]; wrt.writeStartElement("role"); wrt.writeAttribute("id", role); wrt.writeEndElement(); } // write each of the attributes XMLAttributeMarshaller attrMarshaller = new XMLAttributeMarshaller(); Attribute[] vals = value.getAttributes(); for (int i = 0; (vals != null && i < vals.length); i++) { Attribute attr = vals[i]; attrMarshaller.marshall(wrt, attr); } } // end the userdetails.. wrt.writeEndElement(); }
public void export(File f, ConceptMap cmap) { this.cmap = cmap; try (OutputStream outputStream = new FileOutputStream(f)) { out = XMLOutputFactory.newInstance() .createXMLStreamWriter(new OutputStreamWriter(outputStream, "utf-8")); out.writeStartElement("cmap"); out.writeStartElement("map"); writeConceptList(); writeLinkList(); writeConnections(); out.writeEndElement(); out.writeEndElement(); out.writeEndDocument(); out.flush(); } catch (Exception e) { LOG.error(ERROR_MESSAGE, e); } }
public void append( final XMLStreamWriter writer, final EntityInfoAggregator eia, final Map<String, Object> data, final boolean isRootElement, final boolean isFeedPart) throws EntityProviderException { try { writer.writeStartElement(FormatXml.ATOM_ENTRY); if (isRootElement) { writer.writeDefaultNamespace(Edm.NAMESPACE_ATOM_2005); writer.writeNamespace(Edm.PREFIX_M, Edm.NAMESPACE_M_2007_08); writer.writeNamespace(Edm.PREFIX_D, Edm.NAMESPACE_D_2007_08); } if (!isFeedPart) { writer.writeAttribute( Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, "base", properties.getServiceRoot().toASCIIString()); } etag = createETag(eia, data); if (etag != null) { writer.writeAttribute(Edm.NAMESPACE_M_2007_08, FormatXml.M_ETAG, etag); } // write all atom infos (mandatory and optional) appendAtomMandatoryParts(writer, eia, data); appendAtomOptionalParts(writer, eia, data); if (eia.getEntityType().hasStream()) { // write all links appendAtomEditLink(writer, eia, data); appendAtomContentLink(writer, eia, data, properties.getMediaResourceMimeType()); appendAtomNavigationLinks(writer, eia, data); // write properties/content appendCustomProperties(writer, eia, data); appendAtomContentPart(writer, eia, data, properties.getMediaResourceMimeType()); appendProperties(writer, eia, data); } else { // write all links appendAtomEditLink(writer, eia, data); appendAtomNavigationLinks(writer, eia, data); // write properties/content appendCustomProperties(writer, eia, data); writer.writeStartElement(FormatXml.ATOM_CONTENT); writer.writeAttribute(FormatXml.ATOM_TYPE, ContentType.APPLICATION_XML.toString()); appendProperties(writer, eia, data); writer.writeEndElement(); } writer.writeEndElement(); writer.flush(); } catch (Exception e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
protected void writeMessageDefinition( Event parentEvent, MessageEventDefinition messageDefinition, BpmnModel model, XMLStreamWriter xtw) throws Exception { xtw.writeStartElement(ELEMENT_EVENT_MESSAGEDEFINITION); String messageRef = messageDefinition.getMessageRef(); if (StringUtils.isNotEmpty(messageRef)) { // remove the namespace from the message id if set if (messageRef.startsWith(model.getTargetNamespace())) { messageRef = messageRef.replace(model.getTargetNamespace(), ""); messageRef = messageRef.replaceFirst(":", ""); } else { for (String prefix : model.getNamespaces().keySet()) { String namespace = model.getNamespace(prefix); if (messageRef.startsWith(namespace)) { messageRef = messageRef.replace(model.getTargetNamespace(), ""); messageRef = prefix + messageRef; } } } } writeDefaultAttribute(ATTRIBUTE_MESSAGE_REF, messageRef, xtw); boolean didWriteExtensionStartElement = BpmnXMLUtil.writeExtensionElements(messageDefinition, false, xtw); if (didWriteExtensionStartElement) { xtw.writeEndElement(); } xtw.writeEndElement(); }
private void appendAtomMandatoryParts( final XMLStreamWriter writer, final EntityInfoAggregator eia, final Map<String, Object> data) throws EntityProviderException { try { writer.writeStartElement(FormatXml.ATOM_ID); location = properties.getServiceRoot().toASCIIString() + createSelfLink(eia, data, null); writer.writeCharacters(location); writer.writeEndElement(); writer.writeStartElement(FormatXml.ATOM_TITLE); writer.writeAttribute(FormatXml.ATOM_TYPE, FormatXml.ATOM_TEXT); EntityPropertyInfo titleInfo = eia.getTargetPathInfo(EdmTargetPath.SYNDICATION_TITLE); if (titleInfo != null) { EdmSimpleType st = (EdmSimpleType) titleInfo.getType(); Object object = data.get(titleInfo.getName()); String title = st.valueToString(object, EdmLiteralKind.DEFAULT, titleInfo.getFacets()); if (title != null) { writer.writeCharacters(title); } } else { writer.writeCharacters(eia.getEntitySetName()); } writer.writeEndElement(); writer.writeStartElement(FormatXml.ATOM_UPDATED); writer.writeCharacters(getUpdatedString(eia, data)); writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } catch (EdmSimpleTypeException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
@Override public void encodeTagListToWriter(TagList theTagList, Writer theWriter) throws IOException { try { XMLStreamWriter eventWriter = createXmlWriter(theWriter); eventWriter.writeStartElement(TagList.ELEMENT_NAME_LC); eventWriter.writeDefaultNamespace(FHIR_NS); for (Tag next : theTagList) { eventWriter.writeStartElement(TagList.ATTR_CATEGORY); if (isNotBlank(next.getTerm())) { eventWriter.writeAttribute(Tag.ATTR_TERM, next.getTerm()); } if (isNotBlank(next.getLabel())) { eventWriter.writeAttribute(Tag.ATTR_LABEL, next.getLabel()); } if (isNotBlank(next.getScheme())) { eventWriter.writeAttribute(Tag.ATTR_SCHEME, next.getScheme()); } eventWriter.writeEndElement(); } eventWriter.writeEndElement(); eventWriter.close(); } catch (XMLStreamException e) { throw new ConfigurationException("Failed to initialize STaX event factory", e); } }
private void outputIndexEntryEclipseIndexsee( final IndexTerm term, final XMLStreamWriter serializer) throws XMLStreamException { final List<IndexTermTarget> targets = term.getTargetList(); final int targetNum = targets.size(); // Index-see and index-see-also terms should also generate links to its // target // Otherwise, the term won't be displayed in the index tab. if (targets != null && !targets.isEmpty()) { for (int i = 0; i < targetNum; i++) { final IndexTermTarget target = targets.get(i); final String targetUri = target.getTargetURI(); final String targetName = target.getTargetName(); if (targetUri == null) { serializer.writeStartElement("topic"); serializer.writeAttribute("title", target.getTargetName()); serializer.writeEndElement(); // topic } else { serializer.writeStartElement("topic"); serializer.writeAttribute("href", replaceExtName(targetUri)); if (targetName.trim().length() > 0) { serializer.writeAttribute("title", target.getTargetName()); } serializer.writeEndElement(); // topic } } } // end for }
public static void writeMultiInstance(Activity activity, XMLStreamWriter xtw) throws Exception { if (activity.getLoopCharacteristics() != null) { MultiInstanceLoopCharacteristics multiInstanceObject = activity.getLoopCharacteristics(); if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality()) || StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem()) || StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE); BpmnXMLUtil.writeDefaultAttribute( ATTRIBUTE_MULTIINSTANCE_SEQUENTIAL, String.valueOf(multiInstanceObject.isSequential()).toLowerCase(), xtw); if (StringUtils.isNotEmpty(multiInstanceObject.getInputDataItem())) { BpmnXMLUtil.writeQualifiedAttribute( ATTRIBUTE_MULTIINSTANCE_COLLECTION, multiInstanceObject.getInputDataItem(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getElementVariable())) { BpmnXMLUtil.writeQualifiedAttribute( ATTRIBUTE_MULTIINSTANCE_VARIABLE, multiInstanceObject.getElementVariable(), xtw); } if (StringUtils.isNotEmpty(multiInstanceObject.getLoopCardinality())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CARDINALITY); xtw.writeCharacters(multiInstanceObject.getLoopCardinality()); xtw.writeEndElement(); } if (StringUtils.isNotEmpty(multiInstanceObject.getCompletionCondition())) { xtw.writeStartElement(ELEMENT_MULTIINSTANCE_CONDITION); xtw.writeCharacters(multiInstanceObject.getCompletionCondition()); xtw.writeEndElement(); } xtw.writeEndElement(); } } }
private void writeNodes(XMLStreamWriter xmlWriter, HierarchicalGraph graph) throws Exception { if (cancel) { return; } xmlWriter.writeStartElement(NODES); AttributeColumn dynamicCol = dynamicCol = attributeModel.getNodeTable().getColumn(DynamicModel.TIMEINTERVAL_COLUMN); NodeIterable nodeIterable = exportHierarchy ? graph.getNodesTree() : graph.getNodes(); for (Node node : nodeIterable) { xmlWriter.writeStartElement(NODE); String id = node.getNodeData().getId(); xmlWriter.writeAttribute(NODE_ID, id); if (node.getNodeData().getLabel() != null && !node.getNodeData().getLabel().isEmpty()) { xmlWriter.writeAttribute(NODE_LABEL, node.getNodeData().getLabel()); } if (exportHierarchy) { Node parent = graph.getParent(node); if (parent != null) { xmlWriter.writeAttribute(NODE_PID, parent.getNodeData().getId()); } } if (exportDynamic && dynamicCol != null && visibleInterval != null) { TimeInterval timeInterval = (TimeInterval) node.getNodeData().getAttributes().getValue(dynamicCol.getIndex()); if (timeInterval != null) { writeTimeInterval(xmlWriter, timeInterval); } } if (exportAttributes && node.getNodeData().getAttributes() != null) { AttributeRow attributeRow = (AttributeRow) node.getNodeData().getAttributes(); writeAttValues(xmlWriter, attributeRow, visibleInterval); } if (exportSize) { writeNodeSize(xmlWriter, node); } if (exportPosition) { writeNodePosition(xmlWriter, node); } if (exportColors) { writeNodeColor(xmlWriter, node); } xmlWriter.writeEndElement(); Progress.progress(progress); if (cancel) { break; } } xmlWriter.writeEndElement(); }
public static void marshell(VDBMetaData vdb, OutputStream out) throws XMLStreamException, IOException { XMLStreamWriter writer = XMLOutputFactory.newFactory().createXMLStreamWriter(out); writer.writeStartDocument(); writer.writeStartElement(Element.VDB.getLocalName()); writeAttribute(writer, Element.NAME.getLocalName(), vdb.getName()); writeAttribute(writer, Element.VERSION.getLocalName(), String.valueOf(vdb.getVersion())); if (vdb.getDescription() != null) { writeElement(writer, Element.DESCRIPTION, vdb.getDescription()); } writeProperties(writer, vdb.getProperties()); for (VDBImport vdbImport : vdb.getVDBImports()) { writer.writeStartElement(Element.IMPORT_VDB.getLocalName()); writeAttribute(writer, Element.NAME.getLocalName(), vdbImport.getName()); writeAttribute( writer, Element.VERSION.getLocalName(), String.valueOf(vdbImport.getVersion())); writeAttribute( writer, Element.IMPORT_POLICIES.getLocalName(), String.valueOf(vdbImport.isImportDataPolicies())); writer.writeEndElement(); } // models Collection<ModelMetaData> models = vdb.getModelMetaDatas().values(); for (ModelMetaData model : models) { writeModel(writer, model); } // override translators for (Translator translator : vdb.getOverrideTranslators()) { writeTranslator(writer, translator); } // data-roles for (DataPolicy dp : vdb.getDataPolicies()) { writeDataPolicy(writer, dp); } // entry // designer only for (EntryMetaData em : vdb.getEntries()) { writer.writeStartElement(Element.ENTRY.getLocalName()); writeAttribute(writer, Element.PATH.getLocalName(), em.getPath()); if (em.getDescription() != null) { writeElement(writer, Element.DESCRIPTION, em.getDescription()); } writeProperties(writer, em.getProperties()); writer.writeEndElement(); } writer.writeEndElement(); writer.writeEndDocument(); writer.close(); out.close(); }
public void serialize( final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix(xmlWriter, "http://BCXLiqODPCmx.bcx.cl/"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":odpWS200151SOLLIQResult", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "odpWS200151SOLLIQResult", xmlWriter); } } if (localItemoutTracker) { if (localItemout == null) { throw new org.apache.axis2.databinding.ADBException("itemout cannot be null!!"); } localItemout.serialize(new javax.xml.namespace.QName("", "itemout"), xmlWriter); } namespace = ""; writeStartElement(null, namespace, "returnValue", xmlWriter); if (localReturnValue == java.lang.Integer.MIN_VALUE) { throw new org.apache.axis2.databinding.ADBException("returnValue cannot be null!!"); } else { xmlWriter.writeCharacters( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localReturnValue)); } xmlWriter.writeEndElement(); if (localRowsTracker) { if (localRows == null) { throw new org.apache.axis2.databinding.ADBException("rows cannot be null!!"); } localRows.serialize(new javax.xml.namespace.QName("", "rows"), xmlWriter); } xmlWriter.writeEndElement(); }
public void serialize( final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix(xmlWriter, "http://service.web.bio"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":viewSubAdminSystemResponse", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "viewSubAdminSystemResponse", xmlWriter); } } if (local_returnTracker) { if (local_return != null) { for (int i = 0; i < local_return.length; i++) { if (local_return[i] != null) { local_return[i].serialize( new javax.xml.namespace.QName("http://service.web.bio", "return"), xmlWriter); } else { writeStartElement(null, "http://service.web.bio", "return", xmlWriter); // write the nil attribute writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); xmlWriter.writeEndElement(); } } } else { writeStartElement(null, "http://service.web.bio", "return", xmlWriter); // write the nil attribute writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); xmlWriter.writeEndElement(); } } xmlWriter.writeEndElement(); }
protected boolean writeFormProperties( FlowElement flowElement, boolean didWriteExtensionStartElement, XMLStreamWriter xtw) throws Exception { List<FormProperty> propertyList = null; if (flowElement instanceof UserTask) { propertyList = ((UserTask) flowElement).getFormProperties(); } else if (flowElement instanceof StartEvent) { propertyList = ((StartEvent) flowElement).getFormProperties(); } if (propertyList != null) { for (FormProperty property : propertyList) { if (StringUtils.isNotEmpty(property.getId())) { if (didWriteExtensionStartElement == false) { xtw.writeStartElement(ELEMENT_EXTENSIONS); didWriteExtensionStartElement = true; } xtw.writeStartElement( ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_FORMPROPERTY, ACTIVITI_EXTENSIONS_NAMESPACE); writeDefaultAttribute(ATTRIBUTE_FORM_ID, property.getId(), xtw); writeDefaultAttribute(ATTRIBUTE_FORM_NAME, property.getName(), xtw); writeDefaultAttribute(ATTRIBUTE_FORM_TYPE, property.getType(), xtw); writeDefaultAttribute(ATTRIBUTE_FORM_EXPRESSION, property.getExpression(), xtw); writeDefaultAttribute(ATTRIBUTE_FORM_VARIABLE, property.getVariable(), xtw); writeDefaultAttribute(ATTRIBUTE_FORM_DEFAULT, property.getDefaultExpression(), xtw); writeDefaultAttribute(ATTRIBUTE_FORM_DATEPATTERN, property.getDatePattern(), xtw); if (property.isReadable() == false) { writeDefaultAttribute(ATTRIBUTE_FORM_READABLE, ATTRIBUTE_VALUE_FALSE, xtw); } if (property.isWriteable() == false) { writeDefaultAttribute(ATTRIBUTE_FORM_WRITABLE, ATTRIBUTE_VALUE_FALSE, xtw); } if (property.isRequired()) { writeDefaultAttribute(ATTRIBUTE_FORM_REQUIRED, ATTRIBUTE_VALUE_TRUE, xtw); } for (FormValue formValue : property.getFormValues()) { if (StringUtils.isNotEmpty(formValue.getId())) { xtw.writeStartElement( ACTIVITI_EXTENSIONS_PREFIX, ELEMENT_VALUE, ACTIVITI_EXTENSIONS_NAMESPACE); xtw.writeAttribute(ATTRIBUTE_ID, formValue.getId()); xtw.writeAttribute(ATTRIBUTE_NAME, formValue.getName()); xtw.writeEndElement(); } } xtw.writeEndElement(); } } } return didWriteExtensionStartElement; }
public void serialize( final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix(xmlWriter, "urn:partner.soap.sforce.com"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":describeSearchLayoutsResponse", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "describeSearchLayoutsResponse", xmlWriter); } } if (localResultTracker) { if (localResult != null) { for (int i = 0; i < localResult.length; i++) { if (localResult[i] != null) { localResult[i].serialize( new javax.xml.namespace.QName("urn:partner.soap.sforce.com", "result"), xmlWriter); } else { writeStartElement(null, "urn:partner.soap.sforce.com", "result", xmlWriter); // write the nil attribute writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); xmlWriter.writeEndElement(); } } } else { writeStartElement(null, "urn:partner.soap.sforce.com", "result", xmlWriter); // write the nil attribute writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); xmlWriter.writeEndElement(); } } xmlWriter.writeEndElement(); }
public void serialize( final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix(xmlWriter, "urn:fault.ws.rsys.com"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":TableFault", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "TableFault", xmlWriter); } } if (localExceptionCode == null) { writeStartElement(null, "urn:fault.ws.rsys.com", "exceptionCode", xmlWriter); // write the nil attribute writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); xmlWriter.writeEndElement(); } else { localExceptionCode.serialize( new javax.xml.namespace.QName("urn:fault.ws.rsys.com", "exceptionCode"), xmlWriter); } namespace = "urn:fault.ws.rsys.com"; writeStartElement(null, namespace, "exceptionMessage", xmlWriter); if (localExceptionMessage == null) { // write the nil attribute writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); } else { xmlWriter.writeCharacters(localExceptionMessage); } xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); }
public void serialize( final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix( xmlWriter, "http://www.altinn.no/services/Authentication/SystemAuthentication/2009/10"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":GetAuthenticationChallenge", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "GetAuthenticationChallenge", xmlWriter); } } if (localChallengeRequestTracker) { if (localChallengeRequest == null) { writeStartElement( null, "http://www.altinn.no/services/Authentication/SystemAuthentication/2009/10", "challengeRequest", xmlWriter); // write the nil attribute writeAttribute("xsi", "http://www.w3.org/2001/XMLSchema-instance", "nil", "1", xmlWriter); xmlWriter.writeEndElement(); } else { localChallengeRequest.serialize( new javax.xml.namespace.QName( "http://www.altinn.no/services/Authentication/SystemAuthentication/2009/10", "challengeRequest"), xmlWriter); } } xmlWriter.writeEndElement(); }
public static void writeSignalsAndMessages(BpmnModel model, XMLStreamWriter xtw) throws Exception { for (Process process : model.getProcesses()) { for (FlowElement flowElement : process.getFlowElements()) { if (flowElement instanceof Event) { Event event = (Event) flowElement; if (event.getEventDefinitions().size() > 0) { EventDefinition eventDefinition = event.getEventDefinitions().get(0); if (eventDefinition instanceof SignalEventDefinition) { SignalEventDefinition signalEvent = (SignalEventDefinition) eventDefinition; if (model.containsSignalId(signalEvent.getSignalRef()) == false) { Signal signal = new Signal(signalEvent.getSignalRef(), signalEvent.getSignalRef()); model.addSignal(signal); } } else if (eventDefinition instanceof MessageEventDefinition) { MessageEventDefinition messageEvent = (MessageEventDefinition) eventDefinition; if (model.containsMessageId(messageEvent.getMessageRef()) == false) { Message message = new Message(messageEvent.getMessageRef(), messageEvent.getMessageRef(), null); model.addMessage(message); } } } } } } for (Signal signal : model.getSignals()) { xtw.writeStartElement(ELEMENT_SIGNAL); xtw.writeAttribute(ATTRIBUTE_ID, signal.getId()); xtw.writeAttribute(ATTRIBUTE_NAME, signal.getName()); xtw.writeEndElement(); } for (Message message : model.getMessages()) { xtw.writeStartElement(ELEMENT_MESSAGE); String messageId = message.getId(); // remove the namespace from the message id if set if (messageId.startsWith(model.getTargetNamespace())) { messageId = messageId.replace(model.getTargetNamespace(), ""); messageId = messageId.replaceFirst(":", ""); } else { for (String prefix : model.getNamespaces().keySet()) { String namespace = model.getNamespace(prefix); if (messageId.startsWith(namespace)) { messageId = messageId.replace(model.getTargetNamespace(), ""); messageId = prefix + messageId; } } } xtw.writeAttribute(ATTRIBUTE_ID, messageId); xtw.writeAttribute(ATTRIBUTE_NAME, message.getName()); xtw.writeEndElement(); } }
void writeTo(XMLStreamWriter writer) throws XMLStreamException { if (this instanceof SegmentRoute) { writer.writeStartElement("segment"); writer.writeAttribute("path", "/" + ((SegmentRoute) this).name); writer.writeAttribute("terminal", "" + terminal); } else if (this instanceof PatternRoute) { PatternRoute pr = (PatternRoute) this; StringBuilder path = new StringBuilder("/"); for (int i = 0; i < pr.params.length; i++) { path.append(pr.chunks[i]).append("{").append(pr.params[i].name.getValue()).append("}"); } path.append(pr.chunks[pr.chunks.length - 1]); writer.writeStartElement("pattern"); writer.writeAttribute("path", path.toString()); writer.writeAttribute("terminal", Boolean.toString(terminal)); for (PathParam param : pr.params) { writer.writeStartElement("path-param"); writer.writeAttribute("qname", param.name.getValue()); writer.writeAttribute("encodingMode", param.encodingMode.toString()); writer.writeAttribute("pattern", param.matchingRegex.toString()); writer.writeEndElement(); } } else { writer.writeStartElement("route"); } // for (RouteParam routeParam : routeParamArray) { writer.writeStartElement("route-param"); writer.writeAttribute("qname", routeParam.name.getValue()); writer.writeAttribute("value", routeParam.value); writer.writeEndElement(); } // for (RequestParam requestParam : requestParamArray) { writer.writeStartElement("request-param"); writer.writeAttribute("qname", requestParam.name.getValue()); writer.writeAttribute("name", requestParam.matchName); if (requestParam.matchPattern != null) { writer.writeAttribute("value", requestParam.matchPattern.getPattern()); } writer.writeEndElement(); } // /* * for (Map.Entry<String, SegmentRoute[]> entry : segments.entrySet()) { writer.writeStartElement("segment"); * writer.writeAttribute("name", entry.getKey()); for (SegmentRoute segment : entry.getValue()) { * segment.writeTo(writer); } writer.writeEndElement(); } * * // for (PatternRoute pattern : patterns) { pattern.writeTo(writer); } */ // writer.writeEndElement(); }
public void serialize( final javax.xml.namespace.QName parentQName, javax.xml.stream.XMLStreamWriter xmlWriter, boolean serializeType) throws javax.xml.stream.XMLStreamException, org.apache.axis2.databinding.ADBException { java.lang.String prefix = null; java.lang.String namespace = null; prefix = parentQName.getPrefix(); namespace = parentQName.getNamespaceURI(); writeStartElement(prefix, namespace, parentQName.getLocalPart(), xmlWriter); if (serializeType) { java.lang.String namespacePrefix = registerPrefix( xmlWriter, "http://www.intalio.com/BPMS/Workflow/TaskManagementServices-20051109/"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":attachment", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "attachment", xmlWriter); } } if (localAttachmentMetadata == null) { throw new org.apache.axis2.databinding.ADBException("attachmentMetadata cannot be null!!"); } localAttachmentMetadata.serialize( new javax.xml.namespace.QName( "http://www.intalio.com/BPMS/Workflow/TaskManagementServices-20051109/", "attachmentMetadata"), xmlWriter); namespace = "http://www.intalio.com/BPMS/Workflow/TaskManagementServices-20051109/"; writeStartElement(null, namespace, "payloadUrl", xmlWriter); if (localPayloadUrl == null) { // write the nil attribute throw new org.apache.axis2.databinding.ADBException("payloadUrl cannot be null!!"); } else { xmlWriter.writeCharacters(localPayloadUrl); } xmlWriter.writeEndElement(); xmlWriter.writeEndElement(); }
public byte[] convertToXML(BpmnModel model) { try { ByteArrayOutputStream outputStream = new ByteArrayOutputStream(); XMLOutputFactory xof = XMLOutputFactory.newInstance(); OutputStreamWriter out = new OutputStreamWriter(outputStream, "UTF-8"); XMLStreamWriter writer = xof.createXMLStreamWriter(out); XMLStreamWriter xtw = new IndentingXMLStreamWriter(writer); DefinitionsRootExport.writeRootElement(model, xtw); SignalAndMessageDefinitionExport.writeSignalsAndMessages(model, xtw); PoolExport.writePools(model, xtw); for (Process process : model.getProcesses()) { if (process.getFlowElements().size() == 0 && process.getLanes().size() == 0) { // empty process, ignore it continue; } ProcessExport.writeProcess(process, xtw); for (FlowElement flowElement : process.getFlowElements()) { createXML(flowElement, model, xtw); } for (Artifact artifact : process.getArtifacts()) { createXML(artifact, model, xtw); } // end process element xtw.writeEndElement(); } BPMNDIExport.writeBPMNDI(model, xtw); // end definitions root element xtw.writeEndElement(); xtw.writeEndDocument(); xtw.flush(); outputStream.close(); xtw.close(); return outputStream.toByteArray(); } catch (Exception e) { LOGGER.error("Error writing BPMN XML", e); throw new XMLException("Error writing BPMN XML", e); } }