private void appendFunctionImports( final XMLStreamWriter writer, final List<EdmFunctionImport> functionImports, final String containerNamespace) throws XMLStreamException { for (EdmFunctionImport functionImport : functionImports) { writer.writeStartElement(XML_FUNCTION_IMPORT); writer.writeAttribute(XML_NAME, functionImport.getName()); String functionFQNString; FullQualifiedName functionFqn = functionImport.getFunctionFqn(); if (namespaceToAlias.get(functionFqn.getNamespace()) != null) { functionFQNString = namespaceToAlias.get(functionFqn.getNamespace()) + "." + functionFqn.getName(); } else { functionFQNString = functionFqn.getFullQualifiedNameAsString(); } writer.writeAttribute(XML_FUNCTION, functionFQNString); EdmEntitySet returnedEntitySet = functionImport.getReturnedEntitySet(); if (returnedEntitySet != null) { writer.writeAttribute( XML_ENTITY_SET, containerNamespace + "." + returnedEntitySet.getName()); } // Default is false and we do not write the default if (functionImport.isIncludeInServiceDocument()) { writer.writeAttribute( XML_INCLUDE_IN_SERVICE_DOCUMENT, "" + functionImport.isIncludeInServiceDocument()); } writer.writeEndElement(); } }
private void appendSchema(final XMLStreamWriter writer, final EdmSchema schema) throws XMLStreamException { writer.writeStartElement(NS_EDM, SCHEMA); writer.writeDefaultNamespace(NS_EDM); writer.writeAttribute(XML_NAMESPACE, schema.getNamespace()); if (schema.getAlias() != null) { writer.writeAttribute(XML_ALIAS, schema.getAlias()); namespaceToAlias.put(schema.getNamespace(), schema.getAlias()); } // EnumTypes appendEnumTypes(writer, schema.getEnumTypes()); // TypeDefinitions appendTypeDefinitions(writer, schema.getTypeDefinitions()); // EntityTypes appendEntityTypes(writer, schema.getEntityTypes()); // ComplexTypes appendComplexTypes(writer, schema.getComplexTypes()); // Actions appendActions(writer, schema.getActions()); // Functions appendFunctions(writer, schema.getFunctions()); // EntityContainer appendEntityContainer(writer, schema.getEntityContainer()); writer.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); } } }
/** Util method to write an attribute without the ns prefix */ private void writeQNameAttribute( java.lang.String namespace, java.lang.String attName, javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String attributeNamespace = qname.getNamespaceURI(); java.lang.String attributePrefix = xmlWriter.getPrefix(attributeNamespace); if (attributePrefix == null) { attributePrefix = registerPrefix(xmlWriter, attributeNamespace); } java.lang.String attributeValue; if (attributePrefix.trim().length() > 0) { attributeValue = attributePrefix + ":" + qname.getLocalPart(); } else { attributeValue = qname.getLocalPart(); } if (namespace.equals("")) { xmlWriter.writeAttribute(attName, attributeValue); } else { registerPrefix(xmlWriter, namespace); xmlWriter.writeAttribute(namespace, attName, attributeValue); } }
private void appendKey(final XMLStreamWriter writer, final EdmEntityType entityType) throws XMLStreamException { List<EdmKeyPropertyRef> keyPropertyRefs = entityType.getKeyPropertyRefs(); if (keyPropertyRefs != null && !keyPropertyRefs.isEmpty()) { // Resolve Base Type key as it is shown in derived type EdmEntityType baseType = entityType.getBaseType(); if (baseType != null && baseType.getKeyPropertyRefs() != null && !(baseType.getKeyPropertyRefs().isEmpty())) { return; } writer.writeStartElement(XML_KEY); for (EdmKeyPropertyRef keyRef : keyPropertyRefs) { writer.writeEmptyElement(XML_PROPERTY_REF); writer.writeAttribute(XML_NAME, keyRef.getName()); if (keyRef.getAlias() != null) { writer.writeAttribute(XML_ALIAS, keyRef.getAlias()); } } writer.writeEndElement(); } }
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 appendEntityTypes( final XMLStreamWriter writer, final List<EdmEntityType> entityTypes) throws XMLStreamException { for (EdmEntityType entityType : entityTypes) { writer.writeStartElement(XML_ENTITY_TYPE); writer.writeAttribute(XML_NAME, entityType.getName()); if (entityType.hasStream()) { writer.writeAttribute(XML_HAS_STREAM, "" + entityType.hasStream()); } if (entityType.getBaseType() != null) { writer.writeAttribute( XML_BASE_TYPE, getAliasedFullQualifiedName(entityType.getBaseType(), false)); } if (entityType.isAbstract()) { writer.writeAttribute(ABSTRACT, TRUE); } appendKey(writer, entityType); appendProperties(writer, entityType); appendNavigationProperties(writer, entityType); writer.writeEndElement(); } }
private void appendAtomNavigationLink( final XMLStreamWriter writer, final String self, final String navigationPropertyName, final boolean isFeed, final EntityInfoAggregator eia, final Map<String, Object> data) throws EntityProviderException { try { writer.writeStartElement(FormatXml.ATOM_LINK); writer.writeAttribute(FormatXml.ATOM_HREF, self); writer.writeAttribute(FormatXml.ATOM_REL, Edm.NAMESPACE_REL_2007_08 + navigationPropertyName); writer.writeAttribute(FormatXml.ATOM_TITLE, navigationPropertyName); if (isFeed) { writer.writeAttribute( FormatXml.ATOM_TYPE, ContentType.APPLICATION_ATOM_XML_FEED.toString()); appendInlineFeed(writer, navigationPropertyName, eia, data); } else { writer.writeAttribute( FormatXml.ATOM_TYPE, ContentType.APPLICATION_ATOM_XML_ENTRY.toString()); appendInlineEntry(writer, navigationPropertyName, eia, data); } writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderException(EntityProviderException.COMMON, e); } }
@Override public void xmlMe(XMLStreamWriter writer) throws XMLStreamException { writer.writeAttribute("type", "mouseSample"); writer.writeAttribute("time", getWhen() + ""); writer.writeAttribute("mouseX", getMouseX() + ""); writer.writeAttribute("mouseY", getMouseY() + ""); }
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); } }
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); }
@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 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(); }
@Override public void xmlMe(XMLStreamWriter writer) throws XMLStreamException { writer.writeAttribute("type", "insertString"); writer.writeAttribute("time", getWhen() + ""); writer.writeAttribute("offset", getOffset() + ""); writer.writeAttribute("str", getStr()); }
/** 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(); }
private void writeGraph(XMLStreamWriter xmlWriter, HierarchicalGraph graph) throws Exception { xmlWriter.writeStartElement(GRAPH); xmlWriter.writeAttribute( GRAPH_DEFAULT_EDGETYPE, graph instanceof DirectedGraph ? "directed" : graph instanceof UndirectedGraph ? "undirected" : "mixed"); if (exportDynamic) { if (!Double.isInfinite(visibleInterval.getLow())) { String intervalLow = formatTime(visibleInterval.getLow()); xmlWriter.writeAttribute(GRAPH_START, intervalLow); } if (!Double.isInfinite(visibleInterval.getHigh())) { String intervalHigh = formatTime(visibleInterval.getHigh()); xmlWriter.writeAttribute(GRAPH_END, intervalHigh); } String timeFormat = dynamicModel.getTimeFormat().equals(DynamicModel.TimeFormat.DATE) ? "date" : "double"; xmlWriter.writeAttribute(GRAPH_TIMEFORMAT, timeFormat); } xmlWriter.writeAttribute(GRAPH_MODE, exportDynamic ? "dynamic" : "static"); writeAttributes(xmlWriter, attributeModel.getNodeTable()); writeAttributes(xmlWriter, attributeModel.getEdgeTable()); writeNodes(xmlWriter, graph); writeEdges(xmlWriter, graph); xmlWriter.writeEndElement(); }
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 }
@Override public void marshallAsElement(ModelNode resourceModel, XMLStreamWriter writer) throws XMLStreamException { if (resourceModel.hasDefined(getName()) && resourceModel.asInt() > 0) { final ModelNode modules = resourceModel.get(getName()); for (ModelNode module : modules.asList()) { writer.writeStartElement(getXmlName()); writer.writeAttribute(Attribute.CODE.getLocalName(), module.get(CODE).asString()); if (module.hasDefined(Constants.LOGIN_MODULE_STACK_REF)) { writer.writeAttribute( Attribute.LOGIN_MODULE_STACK_REF.getLocalName(), module.get(Constants.LOGIN_MODULE_STACK_REF).asString()); } if (module.hasDefined(Constants.MODULE_OPTIONS)) { for (ModelNode option : module.get(Constants.MODULE_OPTIONS).asList()) { writer.writeEmptyElement(Element.MODULE_OPTION.getLocalName()); writer.writeAttribute(Attribute.NAME.getLocalName(), option.asProperty().getName()); writer.writeAttribute( Attribute.VALUE.getLocalName(), option.asProperty().getValue().asString()); } } writer.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; }
private void writeServiceRef(OsgiServiceBean serviceBean) throws XMLStreamException { writer.writeEmptyElement("reference"); writer.writeAttribute("id", serviceBean.id); writer.writeAttribute("interface", serviceBean.clazz.getName()); if (serviceBean.filter != null && !"".equals(serviceBean.filter)) { writer.writeAttribute("filter", serviceBean.filter); } writer.writeCharacters("\n"); }
private void writeTransactional(TransactionalDef transactionDef) throws XMLStreamException { if (transactionDef != null) { writer.writeCharacters(" "); writer.writeEmptyElement("tx", "transaction", NS_TX); writer.writeAttribute("method", transactionDef.getMethod()); writer.writeAttribute("value", transactionDef.getType()); writer.writeCharacters("\n"); } }
private void writeAtomLink(XMLStreamWriter theEventWriter, String theRel, StringDt theStringDt) throws XMLStreamException { if (StringUtils.isNotBlank(theStringDt.getValue())) { theEventWriter.writeStartElement("link"); theEventWriter.writeAttribute("rel", theRel); theEventWriter.writeAttribute("href", theStringDt.getValue()); theEventWriter.writeEndElement(); } }
public void marshall(XMLStreamWriter wrt, Throwable thr) throws Exception { wrt.writeStartElement("exception"); wrt.writeAttribute("name", thr.getClass().getName()); String msg = thr.getMessage(); if (msg != null) { wrt.writeAttribute("message", thr.getMessage()); } wrt.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(); } }
public void marshall(XMLStreamWriter wrt, ObjectNotFound onf) throws Exception { wrt.writeStartElement("exception"); wrt.writeAttribute("name", onf.getClass().getName()); String msg = onf.getMessage(); if (msg != null) { wrt.writeAttribute("message", onf.getMessage()); } wrt.writeEndElement(); }
private void writeOnlineResource(final XMLStreamWriter writer, final String url) throws XMLStreamException { if (url != null) { writer.writeEmptyElement("OnlineResource"); writer.writeNamespace(XLINK_PREFIX, XLNNS); writer.writeAttribute(XLNNS, "type", "simple"); writer.writeAttribute(XLNNS, "href", url); } }
@Override public void writeXML(XMLStreamWriter writer) throws XMLStreamException { writer.writeEmptyElement("geofence"); writer.writeAttribute("name", nameTextField.getValue()); writer.writeAttribute("operator", getOperator()); writer.writeAttribute("longitude", longitudeTextField.getValue()); writer.writeAttribute("latitude", latitudeTextField.getValue()); writer.writeAttribute("radius", radiusTextField.getValue()); }
private void writePersistenceUnit(Field field) throws XMLStreamException { PersistenceUnit persistenceUnit = field.getAnnotation(PersistenceUnit.class); if (persistenceUnit != null) { writer.writeCharacters(" "); writer.writeEmptyElement("jpa", "context", NS_JPA); writer.writeAttribute("unitname", persistenceUnit.unitName()); writer.writeAttribute("property", field.getName()); writer.writeCharacters("\n"); } }
private void appendActionImports( final XMLStreamWriter writer, final List<EdmActionImport> actionImports) throws XMLStreamException { for (EdmActionImport actionImport : actionImports) { writer.writeStartElement(XML_ACTION_IMPORT); writer.writeAttribute(XML_NAME, actionImport.getName()); writer.writeAttribute( XML_ACTION, getAliasedFullQualifiedName(actionImport.getUnboundAction(), false)); writer.writeEndElement(); } }
private void appendNavigationPropertyBindings( final XMLStreamWriter writer, final EdmBindingTarget bindingTarget) throws XMLStreamException { if (bindingTarget.getNavigationPropertyBindings() != null) { for (EdmNavigationPropertyBinding binding : bindingTarget.getNavigationPropertyBindings()) { writer.writeEmptyElement(XML_NAVIGATION_PROPERTY_BINDING); writer.writeAttribute(XML_PATH, binding.getPath()); writer.writeAttribute(XML_TARGET, binding.getTarget()); } } }