Java Code Examples for javax.xml.stream.XMLStreamWriter#writeEndElement()
The following examples show how to use
javax.xml.stream.XMLStreamWriter#writeEndElement() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: CfgApi.java From aion with MIT License | 8 votes |
public String toXML() { final XMLOutputFactory output = XMLOutputFactory.newInstance(); output.setProperty("escapeCharacters", false); XMLStreamWriter xmlWriter; String xml; try { Writer strWriter = new StringWriter(); xmlWriter = output.createXMLStreamWriter(strWriter); xmlWriter.writeCharacters("\r\n\t"); xmlWriter.writeStartElement("api"); xmlWriter.writeCharacters(this.rpc.toXML()); xmlWriter.writeCharacters(this.zmq.toXML()); xmlWriter.writeCharacters(this.nrg.toXML()); xmlWriter.writeCharacters("\r\n\t"); xmlWriter.writeEndElement(); xml = strWriter.toString(); strWriter.flush(); strWriter.close(); xmlWriter.flush(); xmlWriter.close(); return xml; } catch (IOException | XMLStreamException e) { e.printStackTrace(); return ""; } }
Example 2
Source File: WadlWriter.java From secure-data-service with Apache License 2.0 | 6 votes |
private static final void writeMethod(final Method method, final XMLStreamWriter xsw) throws XMLStreamException { xsw.writeStartElement(WADL_PREFIX, WadlElementName.METHOD.getLocalName(), WadlSyntax.NAMESPACE); try { xsw.writeAttribute(WadlAttributeName.NAME.getLocalName(), method.getVerb()); xsw.writeAttribute(WadlAttributeName.ID.getLocalName(), method.getId()); writeDocumentation(method, xsw); if (method.getRequest() != null) { writeRequest(method.getRequest(), xsw); } for (final Response response : method.getResponses()) { writeResponse(response, xsw); } } finally { xsw.writeEndElement(); } }
Example 3
Source File: XmlMetadataProducer.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private static void writeDocumentation(final Documentation documentation, final Map<String, String> predefinedNamespaces, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { if (documentation != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.DOCUMENTATION); writeAnnotationAttributes(documentation.getAnnotationAttributes(), predefinedNamespaces, null, xmlStreamWriter); if (documentation.getSummary() != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.SUMMARY); xmlStreamWriter.writeCharacters(documentation.getSummary()); xmlStreamWriter.writeEndElement(); } if (documentation.getLongDescription() != null) { xmlStreamWriter.writeStartElement(XmlMetadataConstants.LONG_DESCRIPTION); xmlStreamWriter.writeCharacters(documentation.getLongDescription()); xmlStreamWriter.writeEndElement(); } writeAnnotationElements(documentation.getAnnotationElements(), predefinedNamespaces, xmlStreamWriter); xmlStreamWriter.writeEndElement(); } }
Example 4
Source File: Bug6846132Test.java From openjdk-jdk9 with GNU General Public License v2.0 | 6 votes |
@Test public void testSAXResult() { DefaultHandler handler = new DefaultHandler(); final String EXPECTED_OUTPUT = "<?xml version=\"1.0\"?><root></root>"; try { SAXResult saxResult = new SAXResult(handler); // saxResult.setSystemId("jaxp-ri/unit-test/javax/xml/stream/XMLOutputFactoryTest/cr6846132.xml"); XMLOutputFactory ofac = XMLOutputFactory.newInstance(); XMLStreamWriter writer = ofac.createXMLStreamWriter(saxResult); writer.writeStartDocument("1.0"); writer.writeStartElement("root"); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); writer.close(); } catch (Exception e) { if (e instanceof UnsupportedOperationException) { // expected } else { e.printStackTrace(); Assert.fail(e.toString()); } } }
Example 5
Source File: PatternFormatterResourceDefinition.java From wildfly-core with GNU Lesser General Public License v2.1 | 6 votes |
@Override public void marshallAsElement(final AttributeDefinition attribute, final ModelNode resourceModel, final boolean marshallDefault, final XMLStreamWriter writer) throws XMLStreamException { // We always want to marshal the element writer.writeStartElement(attribute.getXmlName()); // We also need to always marshal the pattern has it's a required attribute in the XML. final String pattern; if (resourceModel.hasDefined(PATTERN.getName())) { pattern = resourceModel.get(PATTERN.getName()).asString(); } else { pattern = PATTERN.getDefaultValue().asString(); } writer.writeAttribute(PATTERN.getXmlName(), pattern); // Only marshal the color-map if defined as this is a newer attribute. if (resourceModel.hasDefined(COLOR_MAP.getName())) { final String colorMap = resourceModel.get(COLOR_MAP.getName()).asString(); writer.writeAttribute(COLOR_MAP.getXmlName(), colorMap); } writer.writeEndElement(); }
Example 6
Source File: DocumentationWriter.java From secure-data-service with Apache License 2.0 | 6 votes |
private static final void writeEnumType(final EnumType enumType, final ModelIndex model, final XMLStreamWriter xsw) throws XMLStreamException { xsw.writeStartElement(DocumentationElements.ENUM_TYPE.getLocalPart()); try { xsw.writeStartElement(DocumentationElements.NAME.getLocalPart()); try { xsw.writeCharacters(enumType.getName()); } finally { xsw.writeEndElement(); } writeDescription(enumType, model, xsw); writeGeneralizations(enumType, model, xsw); for (final EnumLiteral literal : enumType.getLiterals()) { xsw.writeStartElement(DocumentationElements.LITERAL.getLocalPart()); try { xsw.writeAttribute("value", literal.getName()); } finally { xsw.writeEndElement(); } } writeFacets(enumType, model, xsw); } finally { xsw.writeEndElement(); } }
Example 7
Source File: AbstractSTSClient.java From cxf with Apache License 2.0 | 6 votes |
protected void addAppliesTo(XMLStreamWriter writer, String appliesTo) throws XMLStreamException { if (appliesTo != null && addressingNamespace != null) { String policyNS = wspNamespace; if (policyNS == null) { policyNS = "http://schemas.xmlsoap.org/ws/2004/09/policy"; } writer.writeStartElement("wsp", "AppliesTo", policyNS); writer.writeNamespace("wsp", policyNS); writer.writeStartElement("wsa", "EndpointReference", addressingNamespace); writer.writeNamespace("wsa", addressingNamespace); writer.writeStartElement("wsa", "Address", addressingNamespace); writer.writeCharacters(appliesTo); writer.writeEndElement(); writer.writeEndElement(); writer.writeEndElement(); } }
Example 8
Source File: AtomFeedProducer.java From olingo-odata2 with Apache License 2.0 | 6 votes |
private void appendAtomSelfLink(final XMLStreamWriter writer, final EntityInfoAggregator eia) throws EntityProviderException { URI self = properties.getSelfLink(); String selfLink = ""; if (self == null) { selfLink = createSelfLink(eia); } else { selfLink = self.toASCIIString(); } try { writer.writeStartElement(FormatXml.ATOM_LINK); writer.writeAttribute(FormatXml.ATOM_HREF, selfLink); writer.writeAttribute(FormatXml.ATOM_REL, Edm.LINK_REL_SELF); writer.writeAttribute(FormatXml.ATOM_TITLE, eia.getEntitySetName()); writer.writeEndElement(); } catch (XMLStreamException e) { throw new EntityProviderProducerException(EntityProviderException.COMMON, e); } }
Example 9
Source File: XmlIOUtil.java From protostuff with Apache License 2.0 | 6 votes |
/** * Serializes the {@code messages} into the {@link XMLStreamWriter} using the given schema. */ public static <T> void writeListTo(XMLStreamWriter writer, List<T> messages, Schema<T> schema) throws IOException, XMLStreamException { writer.writeStartElement("list"); if (messages.isEmpty()) { writer.writeEndElement(); return; } final String simpleName = schema.messageName(); final XmlOutput output = new XmlOutput(writer, schema); for (T m : messages) { writer.writeStartElement(simpleName); schema.writeTo(output, m); writer.writeEndElement(); } writer.writeEndElement(); }
Example 10
Source File: ProcessTaskExport.java From flowable-engine with Apache License 2.0 | 5 votes |
@Override protected void writePlanItemDefinitionBody(CmmnModel model, ProcessTask processTask, XMLStreamWriter xtw) throws Exception { super.writePlanItemDefinitionBody(model, processTask, xtw); if (StringUtils.isNotEmpty(processTask.getProcessRef()) || StringUtils.isNotEmpty(processTask.getProcessRefExpression())) { xtw.writeStartElement(ELEMENT_PROCESS_REF_EXPRESSION); xtw.writeCData( StringUtils.isNotEmpty(processTask.getProcessRef()) ? processTask.getProcessRef() : processTask.getProcessRefExpression() ); xtw.writeEndElement(); } }
Example 11
Source File: DocumentMetadataPatchBuilderImpl.java From java-client-api with Apache License 2.0 | 5 votes |
@Override public void write(XMLOutputSerializer out) throws Exception { XMLStreamWriter serializer = out.getSerializer(); writeStartInsert(out, "/rapi:metadata/prop:properties", "last-child", null); // TODO: declare namespace on root writeStartElement(out, qname, name); convertFromJava(out, value); serializer.writeEndElement(); serializer.writeEndElement(); }
Example 12
Source File: HtmlExtensionDocWriter.java From nifi-registry with Apache License 2.0 | 5 votes |
private void writeTags(final Extension extension, final XMLStreamWriter xmlStreamWriter) throws XMLStreamException { final List<String> tags = extension.getTags(); xmlStreamWriter.writeStartElement("h3"); xmlStreamWriter.writeCharacters("Tags: "); xmlStreamWriter.writeEndElement(); xmlStreamWriter.writeStartElement("p"); if (tags != null) { final String tagString = StringUtils.join(tags, ", "); xmlStreamWriter.writeCharacters(tagString); } else { xmlStreamWriter.writeCharacters("No tags provided."); } xmlStreamWriter.writeEndElement(); }
Example 13
Source File: DmnXMLUtil.java From activiti6-boot2 with Apache License 2.0 | 5 votes |
public static void writeElementDescription(DmnElement dmnElement, XMLStreamWriter xtw) throws Exception { if (StringUtils.isNotEmpty(dmnElement.getDescription()) && !"null".equalsIgnoreCase(dmnElement.getDescription())) { xtw.writeStartElement(ELEMENT_DESCRIPTION); xtw.writeCharacters(dmnElement.getDescription()); xtw.writeEndElement(); } }
Example 14
Source File: CfgPrune.java From aion with MIT License | 5 votes |
public void toXML(XMLStreamWriter xmlWriter) throws XMLStreamException { xmlWriter.writeCharacters("\r\n\t\t"); xmlWriter.writeStartElement("prune"); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeComment("Boolean value. Enable/disable database pruning."); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeStartElement("enabled"); xmlWriter.writeCharacters(String.valueOf(this.enabled)); xmlWriter.writeEndElement(); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeComment("Boolean value. Enable/disable database archiving."); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeStartElement("archived"); xmlWriter.writeCharacters(String.valueOf(this.archived)); xmlWriter.writeEndElement(); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeComment( "Integer value with minimum set to 128. Only blocks older than best block level minus this number are candidates for pruning."); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeStartElement("current_count"); xmlWriter.writeCharacters(String.valueOf(this.current_count)); xmlWriter.writeEndElement(); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeComment( "Integer value with minimum set to 1000. States for blocks that are exact multiples of this number will not be pruned."); xmlWriter.writeCharacters("\r\n\t\t\t"); xmlWriter.writeStartElement("archive_rate"); xmlWriter.writeCharacters(String.valueOf(this.archive_rate)); xmlWriter.writeEndElement(); xmlWriter.writeCharacters("\r\n\t\t"); xmlWriter.writeEndElement(); }
Example 15
Source File: XmlErrorDocumentProducer.java From cloud-odata-java with Apache License 2.0 | 5 votes |
public void writeErrorDocument(final XMLStreamWriter writer, final String errorCode, final String message, final Locale locale, final String innerError) throws XMLStreamException { writer.writeStartDocument(); writer.writeStartElement(FormatXml.M_ERROR); writer.writeDefaultNamespace(Edm.NAMESPACE_M_2007_08); writer.writeStartElement(FormatXml.M_CODE); if (errorCode != null) { writer.writeCharacters(errorCode); } writer.writeEndElement(); writer.writeStartElement(FormatXml.M_MESSAGE); if (locale != null) { writer.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_LANG, getLocale(locale)); } else { writer.writeAttribute(Edm.PREFIX_XML, Edm.NAMESPACE_XML_1998, FormatXml.XML_LANG, ""); } if (message != null) { writer.writeCharacters(message); } writer.writeEndElement(); if (innerError != null) { writer.writeStartElement(FormatXml.M_INNER_ERROR); writer.writeCharacters(innerError); writer.writeEndElement(); } writer.writeEndDocument(); }
Example 16
Source File: frmSettings.java From Course_Generator with GNU General Public License v3.0 | 5 votes |
private void SaveTheme() { String s = Utils.SaveDialog(this, DataDir + "/" + CgConst.CG_DIR + "/themes/", "", ".theme", bundle.getString("frmMain.themeFile"), true, bundle.getString("frmMain.FileExist")); if (!s.isEmpty()) { // -- Save the data in the home directory XMLOutputFactory factory = XMLOutputFactory.newInstance(); try { BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(new FileOutputStream(s)); XMLStreamWriter writer = new IndentingXMLStreamWriter( factory.createXMLStreamWriter(bufferedOutputStream, "UTF-8")); writer.writeStartDocument("UTF-8", "1.0"); writer.writeComment("Course Generator (C) Pierre DELORE"); writer.writeStartElement("THEME"); Utils.WriteIntToXML(writer, "COLORDIFFVERYEASY", ColorVeryEasy.getRGB()); Utils.WriteIntToXML(writer, "COLORDIFFEASY", ColorEasy.getRGB()); Utils.WriteIntToXML(writer, "COLORDIFFAVERAGE", ColorAverage.getRGB()); Utils.WriteIntToXML(writer, "COLORDIFFHARD", ColorHard.getRGB()); Utils.WriteIntToXML(writer, "COLORDIFFVERYHARD", ColorVeryHard.getRGB()); Utils.WriteIntToXML(writer, "COLORNIGHT", ColorNight.getRGB()); Utils.WriteIntToXML(writer, "NORMALTRACKWIDTH", spinNormalTrackWidth.getValueAsInt()); Utils.WriteIntToXML(writer, "NIGHTTRACKWIDTH", spinNightTrackWidth.getValueAsInt()); Utils.WriteIntToXML(writer, "NORMALTRACKTRANSPARENCY", spinNormalTrackTransparency.getValueAsInt()); Utils.WriteIntToXML(writer, "NIGHTTRACKTRANSPARENCY", spinNightTrackTransparency.getValueAsInt()); writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); writer.close(); bufferedOutputStream.close(); } catch (XMLStreamException | IOException e) { e.printStackTrace(); } } }
Example 17
Source File: TableauMessageBodyGenerator.java From dremio-oss with Apache License 2.0 | 5 votes |
private void writeOdbcConnection(XMLStreamWriter xmlStreamWriter, DatasetConfig datasetConfig, String hostname) throws XMLStreamException { DatasetPath dataset = new DatasetPath(datasetConfig.getFullPathList()); xmlStreamWriter.writeStartElement("connection"); xmlStreamWriter.writeAttribute("class", "genericodbc"); xmlStreamWriter.writeAttribute("dbname", InfoSchemaConstants.IS_CATALOG_NAME); // Create advanced properties string final StringBuilder extraProperties = new StringBuilder(); final String customExtraProperties = optionManager.getOption(EXTRA_CONNECTION_PROPERTIES); // Writing custom extra properties first as they will take precedence over default ones if (!customExtraProperties.isEmpty()) { extraProperties.append(customExtraProperties).append(";"); } extraProperties.append("AUTHENTICATIONTYPE=Basic Authentication;CONNECTIONTYPE=Direct;HOST="); extraProperties.append(hostname); xmlStreamWriter.writeAttribute("odbc-connect-string-extras", extraProperties.toString()); // It has to match what is returned by the driver/Tableau xmlStreamWriter.writeAttribute("odbc-dbms-name", "Dremio"); xmlStreamWriter.writeAttribute("odbc-driver", "Dremio Connector"); xmlStreamWriter.writeAttribute("odbc-dsn", ""); xmlStreamWriter.writeAttribute("odbc-suppress-connection-pooling", ""); xmlStreamWriter.writeAttribute("odbc-use-connection-pooling", ""); xmlStreamWriter.writeAttribute("schema", dataset.toParentPath()); xmlStreamWriter.writeAttribute("port", String.valueOf(endpoint.getUserPort())); xmlStreamWriter.writeAttribute("server", ""); xmlStreamWriter.writeAttribute("username", ""); writeRelation(xmlStreamWriter, datasetConfig); if (customizationEnabled) { writeConnectionCustomization(xmlStreamWriter); } xmlStreamWriter.writeEndElement(); }
Example 18
Source File: InitiatorEncryptionToken.java From steady with Apache License 2.0 | 5 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getRealName().getLocalPart(); String namespaceURI = getRealName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getRealName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:InitiatorEncryptionToken> writer.writeStartElement(prefix, localName, namespaceURI); String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(pPrefix, SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); Token token = getInitiatorEncryptionToken(); if (token == null) { throw new RuntimeException("InitiatorEncryptionToken doesn't contain any token assertions"); } token.serialize(writer); // </wsp:Policy> writer.writeEndElement(); // </sp:InitiatorToken> writer.writeEndElement(); }
Example 19
Source File: SpnegoContextToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { QName name = constants.getSpnegoContextToken(); String localname = name.getLocalPart(); String namespaceURI = name.getNamespaceURI(); String prefix; String writerPrefix = writer.getPrefix(namespaceURI); if (writerPrefix == null) { prefix = name.getPrefix(); writer.setPrefix(prefix, namespaceURI); } else { prefix = writerPrefix; } // <sp:SpnegoContextToken> writer.writeStartElement(prefix, localname, namespaceURI); if (writerPrefix == null) { // xmlns:sp=".." writer.writeNamespace(prefix, namespaceURI); } String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (issuerEpr != null) { // <sp:Issuer> writer.writeStartElement(prefix, SPConstants.ISSUER, namespaceURI); StaxUtils.copy(issuerEpr, writer); writer.writeEndElement(); } if (isDerivedKeys()) { String wspNamespaceURI = SPConstants.POLICY.getNamespaceURI(); String wspPrefix; String wspWriterPrefix = writer.getPrefix(wspNamespaceURI); if (wspWriterPrefix == null) { wspPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(wspPrefix, wspNamespaceURI); } else { wspPrefix = wspWriterPrefix; } // <wsp:Policy> writer.writeStartElement(wspPrefix, SPConstants.POLICY.getLocalPart(), wspNamespaceURI); if (wspWriterPrefix == null) { // xmlns:wsp=".." writer.writeNamespace(wspPrefix, wspNamespaceURI); } if (isDerivedKeys()) { // <sp:RequireDerivedKeys /> writer.writeEmptyElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); } // </wsp:Policy> writer.writeEndElement(); } // </sp:SpnegoContextToken> writer.writeEndElement(); }
Example 20
Source File: SamlToken.java From steady with Apache License 2.0 | 4 votes |
public void serialize(XMLStreamWriter writer) throws XMLStreamException { QName name = constants.getSamlToken(); String localname = name.getLocalPart(); String namespaceURI = name.getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = name.getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:SamlToken writer.writeStartElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); String inclusion; inclusion = constants.getAttributeValueFromInclusion(getInclusion()); if (inclusion != null) { writer.writeAttribute(prefix, namespaceURI, SPConstants.ATTR_INCLUDE_TOKEN, inclusion); } if (isUseSamlVersion11Profile10() || isUseSamlVersion11Profile11() || isUseSamlVersion20Profile11()) { String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { pPrefix = SPConstants.POLICY.getPrefix(); writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement(pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY .getNamespaceURI()); // CHECKME if (isUseSamlVersion11Profile10()) { // <sp:WssSamlV11Token10 /> writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_10, namespaceURI); } else if (isUseSamlVersion11Profile11()) { // <sp:WssSamlV11Token11 /> writer.writeStartElement(prefix, SPConstants.SAML_11_TOKEN_11, namespaceURI); } else { // <sp:WssSamlV20Token11 /> writer.writeStartElement(prefix, SPConstants.SAML_20_TOKEN_11, namespaceURI); } if (isDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } else if (isExplicitDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_EXPLICIT_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } else if (isImpliedDerivedKeys()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_IMPLIED_DERIVED_KEYS, namespaceURI); writer.writeEndElement(); } if (isRequireKeyIdentifierReference()) { writer.writeStartElement(prefix, SPConstants.REQUIRE_KEY_IDENTIFIER_REFERENCE, namespaceURI); writer.writeEndElement(); } writer.writeEndElement(); // </wsp:Policy> writer.writeEndElement(); } writer.writeEndElement(); // </sp:SamlToken> }