List of utility methods to do XML Namespace
Document | readXML(InputStream input, boolean isNamespaceAware) Parses the given input stream and returns the corresponding desirialized XML document. return readXML(new InputStreamReader(input, "UTF-8"), isNamespaceAware); |
Document | stringToDoc(String s, boolean nameSpaceAware) /* Parse an XML string into a DOM document DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance(); domFactory.setNamespaceAware(nameSpaceAware); DocumentBuilder docBuilder = domFactory.newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(s)); Document doc = docBuilder.parse(is); return doc; |
void | writeNamespace(XMLStreamWriter out, String prefix, String namespaceURI) Write the namespace if necessary. NamespaceContext namespaceContext = out.getNamespaceContext(); boolean writeNamespace = (namespaceContext.getPrefix(namespaceURI) == null); if (writeNamespace) { out.setPrefix(prefix, namespaceURI); out.writeNamespace(prefix, namespaceURI); |
void | writeNamespace(XMLStreamWriter writer, String prefix, String namespaceURI) write Namespace if (prefix == null || NO_PREFIX.equals(prefix)) { writer.writeDefaultNamespace(namespaceURI); } else { writer.writeNamespace(prefix, namespaceURI); |
void | writeNamespaceDeclarations(final XMLStreamWriter writer, final Iterable write Namespace Declarations for (Entry<URI, String> e : prefixes) { final String ns = e.getKey().toString(); final String p = e.getValue(); writer.writeNamespace(p, ns); |
void | writeNamespaceIfNotBound(XMLStreamWriter xmlStream, String prefix, String nsUri) write Namespace If Not Bound if (!prefix.equals(xmlStream.getPrefix(nsUri))) {
xmlStream.writeNamespace(prefix, nsUri);
|
void | writeNamespaces(XMLStreamWriter writer, Iterator namespaces) write Namespaces while (namespaces.hasNext()) {
Namespace ns = (Namespace) namespaces.next();
writer.writeNamespace(ns.getPrefix(), ns.getNamespaceURI());
|