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); }
protected void writeStartElementWithNS(String namespaceURI, String localname) throws XMLStreamException { if (namespaceURI == null || namespaceURI.length() == 0) { writer.writeStartElement(localname); } else { if (writer.getNamespaceContext().getPrefix(namespaceURI) == null) { String prefix = nsToPrefix.get(namespaceURI); if (prefix != null) { writer.writeStartElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); } else { nsToPrefix.put("ns" + ++prefixIndex, namespaceURI); LOG.warn( "No prefix for namespace '{}' configured. Using {}.", namespaceURI, "ns" + prefixIndex); writer.writeStartElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); } } else { writer.writeStartElement(namespaceURI, localname); } } }
private void writeElement(final StartElement element) throws XMLStreamException { final String name = element.getLocalName(); final String uri = element.getNamespace(); String prefix = element.getPrefix(); if (uri != null) { if (nsuris.containsKey(uri)) { final List namespaceTrace = nsuris.get(uri); final Integer deepLevelInMAp = (Integer) namespaceTrace.get(0); final String prefixTrace = (String) namespaceTrace.get(2); if (prefixTrace == null || !prefixTrace.equals(prefix)) { prefix = prefixTrace; } if (deepLevelInMAp >= this.deepLevel) { writer.writeStartElement(prefix, name, uri); writer.writeNamespace(prefix, uri); } else { writer.writeStartElement(prefix, name, uri); } } else { final List namespaceTrace = new ArrayList(); namespaceTrace.add(this.deepLevel); namespaceTrace.add(name); namespaceTrace.add(prefix); nsuris.put(uri, namespaceTrace); writer.writeStartElement(prefix, name, uri); writer.writeNamespace(prefix, uri); } } else { writer.writeStartElement(name); } }
private void writeBlueprint() throws XMLStreamException { writer.writeStartElement("blueprint"); writer.writeDefaultNamespace(NS_BLUEPRINT); writer.writeNamespace("ext", NS_EXT); writer.writeNamespace("jpa", NS_JPA); writer.writeNamespace("tx", NS_TX); writer.writeCharacters("\n"); }
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); } }
/** * Creates the <a href="http://wiki.mindmakers.org/projects:BML:main">Behavior Markup Language</a> * string for Avatar. * * @param utterance the utterance to speak <code>null</code> * @param ssml SSML with BML annotations * @return created XML string * @throws XMLStreamException if the stream could not be created. */ private String createBML(final String utterance, final SsmlDocument ssml) throws XMLStreamException { final ByteArrayOutputStream out = new ByteArrayOutputStream(); final XMLOutputFactory factory = XMLOutputFactory.newInstance(); final XMLStreamWriter writer = factory.createXMLStreamWriter(out, ENCODING); writer.writeStartDocument(ENCODING, "1.0"); writer.writeStartElement("bml"); writer.writeAttribute("id", "bml1"); writer.writeNamespace("ns1", BML_NAMESPACE_URI); if (ssml != null) { final Speak speak = ssml.getSpeak(); final NodeList children = speak.getChildNodes(); for (int i = 0; i < children.getLength(); i++) { final Node child = children.item(i); final String namespace = child.getNamespaceURI(); if (namespace != null) { writeBMLNode(writer, child, utterance); } } } writer.writeEndElement(); writer.writeEndDocument(); writer.flush(); // lastGestureEndTime = 0; writer.close(); try { String output = out.toString(ENCODING); return output; } catch (UnsupportedEncodingException e) { LOGGER.warn(e.getMessage(), e); return out.toString(); } }
/** Register a namespace prefix */ private java.lang.String registerPrefix( javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { java.lang.String prefix = xmlWriter.getPrefix(namespace); if (prefix == null) { prefix = generatePrefix(namespace); javax.xml.namespace.NamespaceContext nsContext = xmlWriter.getNamespaceContext(); while (true) { java.lang.String uri = nsContext.getNamespaceURI(prefix); if ((uri == null) || (uri.length() == 0)) { break; } prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); } xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } return prefix; }
private void writeAttribute( final String uri, final String elementName, final String attributeName, final String attributeValue, String prefix) throws XMLStreamException { if (uri != null) { if (nsuris.containsKey(uri)) { final List namespaceTrace = nsuris.get(uri); final String prefixTrace = (String) namespaceTrace.get(2); if (!prefixTrace.equals(prefix)) { prefix = prefixTrace; } } else { final List namespaceTrace = new ArrayList(); namespaceTrace.add(this.deepLevel); namespaceTrace.add(elementName); namespaceTrace.add(prefix); nsuris.put(uri, namespaceTrace); writer.writeNamespace(prefix, uri); } } writer.writeAttribute(prefix, uri, attributeName, attributeValue); }
/** method to handle Qnames */ private void writeQName( javax.xml.namespace.QName qname, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String namespaceURI = qname.getNamespaceURI(); if (namespaceURI != null) { java.lang.String prefix = xmlWriter.getPrefix(namespaceURI); if (prefix == null) { prefix = generatePrefix(namespaceURI); xmlWriter.writeNamespace(prefix, namespaceURI); xmlWriter.setPrefix(prefix, namespaceURI); } if (prefix.trim().length() > 0) { xmlWriter.writeCharacters( prefix + ":" + org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); } else { // i.e this is the default namespace xmlWriter.writeCharacters( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); } } else { xmlWriter.writeCharacters( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qname)); } }
public void serialize( final javax.xml.namespace.QName parentQName, 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(); if ((namespace != null) && (namespace.trim().length() > 0)) { java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); if (writerPrefix != null) { xmlWriter.writeStartElement(namespace, parentQName.getLocalPart()); } else { if (prefix == null) { prefix = generatePrefix(namespace); } xmlWriter.writeStartElement(prefix, parentQName.getLocalPart(), namespace); xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } } else { xmlWriter.writeStartElement(parentQName.getLocalPart()); } if (serializeType) { java.lang.String namespacePrefix = registerPrefix(xmlWriter, "http://www.w3.org/2001/XMLSchema"); if ((namespacePrefix != null) && (namespacePrefix.trim().length() > 0)) { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", namespacePrefix + ":integer", xmlWriter); } else { writeAttribute( "xsi", "http://www.w3.org/2001/XMLSchema-instance", "type", "integer", xmlWriter); } } if (localInteger == null) { // write the nil attribute throw new org.apache.axis2.databinding.ADBException("integer cannot be null!!"); } else { xmlWriter.writeCharacters( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(localInteger)); } xmlWriter.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); } }
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String localName = getName().getLocalPart(); String namespaceURI = getName().getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = getName().getPrefix(); writer.setPrefix(prefix, namespaceURI); } writer.writeStartElement(prefix, localName, namespaceURI); writer.writeNamespace(prefix, namespaceURI); // <wsp:Policy> writer.writeStartElement( SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI()); // writer.writeStartElement(prefix, getAlgoSuiteString(), namespaceURI); writer.writeEndElement(); if (SPConstants.C14N.equals(getInclusiveC14n())) { writer.writeStartElement(prefix, SPConstants.INCLUSIVE_C14N, namespaceURI); writer.writeEndElement(); } if (SPConstants.SNT.equals(getSoapNormalization())) { writer.writeStartElement(prefix, SPConstants.SOAP_NORMALIZATION_10, namespaceURI); writer.writeEndElement(); } if (SPConstants.STRT10.equals(getStrTransform())) { writer.writeStartElement(prefix, SPConstants.STR_TRANSFORM_10, namespaceURI); writer.writeEndElement(); } if (SPConstants.XPATH.equals(getXPath())) { writer.writeStartElement(prefix, SPConstants.XPATH10, namespaceURI); writer.writeEndElement(); } if (SPConstants.XPATH20.equals(getXPath())) { writer.writeStartElement(prefix, SPConstants.XPATH_FILTER20, namespaceURI); writer.writeEndElement(); } // </wsp:Policy> writer.writeEndElement(); // </sp:AlgorithmSuite> writer.writeEndElement(); }
/** Util method to write an attribute with the ns prefix */ private void writeAttribute( java.lang.String prefix, java.lang.String namespace, java.lang.String attName, java.lang.String attValue, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { if (xmlWriter.getPrefix(namespace) == null) { xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } xmlWriter.writeAttribute(namespace, attName, attValue); }
private void writeAttribute( final String prefix, final String namespace, final String attName, final String attValue, final XMLStreamWriter xmlWriter) throws XMLStreamException { if (xmlWriter.getPrefix(namespace) == null) { xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } xmlWriter.writeAttribute(namespace, attName, attValue); }
public void writeMetadataDocument(final XMLStreamWriter writer) throws XMLStreamException { writer.writeStartDocument(ODataSerializer.DEFAULT_CHARSET, "1.0"); writer.setPrefix(PREFIX_EDMX, NS_EDMX); writer.setDefaultNamespace(NS_EDMX); writer.writeStartElement(PREFIX_EDMX, EDMX, NS_EDMX); writer.writeAttribute("Version", "4.0"); writer.writeNamespace(PREFIX_EDMX, NS_EDMX); appendReference(writer); appendDataServices(writer); writer.writeEndDocument(); }
public void writeXmlns(String prefix, String uri) { try { if (prefix.length() == 0) { out.setDefaultNamespace(uri); } else { out.setPrefix(prefix, uri); } // this method handles "", null, and "xmlns" prefixes properly out.writeNamespace(prefix, uri); } catch (XMLStreamException e) { throw new TxwException(e); } }
@Override public void writeStart(final Optional<String> title) throws IOException { try { xmlWriter.writeStartDocument(); xmlWriter.setDefaultNamespace(NAMESPACE); xmlWriter.writeStartElement("report"); xmlWriter.writeNamespace(null, NAMESPACE); if (title.isPresent()) { xmlWriter.writeAttribute("title", title.get()); } } catch (XMLStreamException e) { throw new IOException(e); } }
/** Register a namespace prefix */ private java.lang.String registerPrefix( javax.xml.stream.XMLStreamWriter xmlWriter, java.lang.String namespace) throws javax.xml.stream.XMLStreamException { java.lang.String prefix = xmlWriter.getPrefix(namespace); if (prefix == null) { prefix = generatePrefix(namespace); while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { prefix = org.apache.axis2.databinding.utils.BeanUtil.getUniquePrefix(); } xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } return prefix; }
private String registerPrefix(final XMLStreamWriter xmlWriter, final String namespace) throws XMLStreamException { String prefix = xmlWriter.getPrefix(namespace); if (prefix == null) { prefix = OperationRequestType.generatePrefix(namespace); while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { prefix = BeanUtil.getUniquePrefix(); } xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } return prefix; }
public void serialize(XMLStreamWriter writer) throws XMLStreamException { String wspPrefix = writer.getPrefix(Constants.URI_POLICY_NS); if (wspPrefix == null) { wspPrefix = Constants.ATTR_WSP; writer.setPrefix(wspPrefix, Constants.URI_POLICY_NS); } writer.writeStartElement(wspPrefix, Constants.ELEM_POLICY_REF, Constants.URI_POLICY_NS); writer.writeNamespace(Constants.ATTR_WSP, Constants.URI_POLICY_NS); writer.writeAttribute(Constants.ATTR_URI, getURI()); writer.writeEndElement(); }
@SuppressWarnings("unused") private String registerPrefix(final XMLStreamWriter xmlWriter, final String namespace) throws XMLStreamException { String prefix = xmlWriter.getPrefix(namespace); if (prefix == null) { prefix = GetStatus.generatePrefix(namespace); while (xmlWriter.getNamespaceContext().getNamespaceURI(prefix) != null) { prefix = BeanUtil.getUniquePrefix(); } xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } return prefix; }
public void writeSchema(XMLStreamWriter out) throws XMLStreamException, JAXBException { out.writeStartElement("xsd", "schema", W3C_XML_SCHEMA_NS_URI); out.writeAttribute("version", "1.0"); out.writeAttribute("targetNamespace", _namespace); out.writeNamespace(TARGET_NAMESPACE_PREFIX, _namespace); _context.generateSchemaWithoutHeader(out); for (AbstractAction action : _actionNames.values()) action.writeSchema(out, _namespace, _context); out.writeEndElement(); // schema out.flush(); }
public static String getEndpointDescriptionXML(EndpointDescription endpoint) throws XMLStreamException { Map<String, Object> properties = endpoint.getProperties(); StringWriter writer = new StringWriter(); XMLStreamWriter xml = XMLOutputFactory.newInstance().createXMLStreamWriter(writer); xml.writeStartDocument(); xml.setDefaultNamespace(REMOTE_SERVICES_ADMIN_NS); xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, ENDPOINT_DESCRIPTIONS); xml.writeNamespace("", REMOTE_SERVICES_ADMIN_NS); xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, ENDPOINT_DESCRIPTION); for (Map.Entry<String, Object> entry : properties.entrySet()) { String key = entry.getKey(); Object val = entry.getValue(); xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, PROPERTY); xml.writeAttribute(NAME, key); if (val.getClass().isArray()) { setValueType(xml, val.getClass().getComponentType().getName()); xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, ARRAY); for (int i = 0, l = Array.getLength(val); i < l; i++) { xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, VALUE); xml.writeCharacters(Array.get(val, i).toString()); xml.writeEndElement(); } xml.writeEndElement(); } else if (val instanceof List) { xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, LIST); handleCollectionValue(xml, (Collection) val); xml.writeEndElement(); } else if (val instanceof Set) { xml.writeStartElement(REMOTE_SERVICES_ADMIN_NS, SET); handleCollectionValue(xml, (Collection) val); xml.writeEndElement(); } else { xml.writeAttribute(VALUE, val.toString()); setValueType(xml, val.getClass().getName()); } xml.writeEndElement(); } xml.writeEndElement(); xml.writeEndElement(); xml.writeEndDocument(); xml.close(); return writer.toString(); }
private void writeQNames( javax.xml.namespace.QName[] qnames, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { if (qnames != null) { // we have to store this data until last moment since it is not possible to write any // namespace data after writing the charactor data java.lang.StringBuffer stringToWrite = new java.lang.StringBuffer(); java.lang.String namespaceURI = null; java.lang.String prefix = null; for (int i = 0; i < qnames.length; i++) { if (i > 0) { stringToWrite.append(" "); } namespaceURI = qnames[i].getNamespaceURI(); if (namespaceURI != null) { prefix = xmlWriter.getPrefix(namespaceURI); if ((prefix == null) || (prefix.length() == 0)) { prefix = generatePrefix(namespaceURI); xmlWriter.writeNamespace(prefix, namespaceURI); xmlWriter.setPrefix(prefix, namespaceURI); } if (prefix.trim().length() > 0) { stringToWrite .append(prefix) .append(":") .append( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); } else { stringToWrite.append( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); } } else { stringToWrite.append( org.apache.axis2.databinding.utils.ConverterUtil.convertToString(qnames[i])); } } xmlWriter.writeCharacters(stringToWrite.toString()); } }
public void XtestNamespaceAsLastItem1() throws Exception { MutableXMLStreamBuffer xsb = new MutableXMLStreamBuffer(); XMLStreamWriter w = xsb.createFromXMLStreamWriter(); // new StreamWriterBufferCreator(xsb); w.writeStartElement("p1", "tag", "ns1"); w.writeAttribute("a", "x"); w.writeNamespace("p", "ns"); w.writeEndElement(); XMLStreamReader xr = xsb.readAsXMLStreamReader(); boolean tested = false; while (xr.hasNext()) { int i = xr.next(); // if (xr.isStartElement() && xr.getLocalName().equals("tag")) { // assertEquals(1,xr.getAttributeCount()); // assertEquals("ns",xr.getNamespaceURI("p")); // tested = true; // } } // assertTrue(tested); }
public void serialize(XMLStreamWriter writer) throws XMLStreamException { QName name = constants.getUserNameToken(); String localname = name.getLocalPart(); String namespaceURI = name.getNamespaceURI(); String prefix = writer.getPrefix(namespaceURI); if (prefix == null) { prefix = name.getPrefix(); writer.setPrefix(prefix, namespaceURI); } // <sp:KeyValueToken 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 (forceRsaKeyValue) { String pPrefix = writer.getPrefix(SPConstants.POLICY.getNamespaceURI()); if (pPrefix == null) { writer.setPrefix(SPConstants.POLICY.getPrefix(), SPConstants.POLICY.getNamespaceURI()); } // <wsp:Policy> writer.writeStartElement( pPrefix, SPConstants.POLICY.getLocalPart(), SPConstants.POLICY.getNamespaceURI()); writer.writeEmptyElement(prefix, "RsaKeyValue", namespaceURI); // </wsp:Policy> writer.writeEndElement(); } writer.writeEndElement(); // </sp:KeyValueToken> }
/** Utility method to write an element start tag. */ private void writeStartElement( java.lang.String prefix, java.lang.String namespace, java.lang.String localPart, javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); if (writerPrefix != null) { xmlWriter.writeStartElement(namespace, localPart); } else { if ((namespace.length()) == 0) { prefix = ""; } else if (prefix == null) { prefix = hr.ponge.pfa.axis.env.operations.UpdateUserResp.generatePrefix(namespace); } xmlWriter.writeStartElement(prefix, localPart, namespace); xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } }
protected void writeAttributeWithNS(String namespaceURI, String localname, String value) throws XMLStreamException { if (namespaceURI == null || namespaceURI.length() == 0) { writer.writeAttribute(localname, value); } else { String prefix = writer.getNamespaceContext().getPrefix(namespaceURI); if (prefix == null) { prefix = nsToPrefix.get(namespaceURI); if (prefix != null) { writer.setPrefix(prefix, namespaceURI); writer.writeNamespace(prefix, namespaceURI); } else { LOG.warn( "No prefix for namespace '{}' configured. Depending on XMLStream auto-repairing.", namespaceURI); } } writer.writeAttribute(prefix, namespaceURI, localname, value); } }
protected void writeEmptyElementWithNS(String namespaceURI, String localname) throws XMLStreamException { if (namespaceURI == null || namespaceURI.length() == 0) { writer.writeEmptyElement(localname); } else { if (writer.getNamespaceContext().getPrefix(namespaceURI) == null) { String prefix = nsToPrefix.get(namespaceURI); if (prefix != null) { writer.writeEmptyElement(prefix, localname, namespaceURI); writer.writeNamespace(prefix, namespaceURI); } else { LOG.warn( "No prefix for namespace '{}' configured. Depending on XMLStream auto-repairing.", namespaceURI); writer.writeEmptyElement(namespaceURI, localname); } } else { writer.writeEmptyElement(namespaceURI, localname); } } }
private void writeStartElement( java.lang.String prefix, final java.lang.String namespace, final java.lang.String localPart, final javax.xml.stream.XMLStreamWriter xmlWriter) throws javax.xml.stream.XMLStreamException { final java.lang.String writerPrefix = xmlWriter.getPrefix(namespace); if (writerPrefix != null) { xmlWriter.writeStartElement(namespace, localPart); } else { if (namespace.length() == 0) { prefix = ""; } else if (prefix == null) { prefix = ConsultaCadastro2Result.generatePrefix(namespace); } xmlWriter.writeStartElement(prefix, localPart, namespace); xmlWriter.writeNamespace(prefix, namespace); xmlWriter.setPrefix(prefix, namespace); } }