Java Code Examples for javax.xml.stream.XMLStreamWriter#getNamespaceContext()
The following examples show how to use
javax.xml.stream.XMLStreamWriter#getNamespaceContext() .
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: OutTransformWriter.java From cxf with Apache License 2.0 | 6 votes |
public OutTransformWriter(XMLStreamWriter writer, Map<String, String> outEMap, Map<String, String> append, List<String> dropEls, Map<String, String> outAMap, boolean attributesToElements, String defaultNamespace) { super(writer); elementsMap = new QNamesMap(outEMap == null ? 0 : outEMap.size()); attributesMap = new QNamesMap(outAMap == null ? 0 : outAMap.size()); TransformUtils.convertToQNamesMap(outEMap, elementsMap, nsMap); TransformUtils.convertToQNamesMap(outAMap, attributesMap, null); TransformUtils.convertToMapOfElementProperties(append, appendMap); dropElements = DOMUtils.convertStringsToQNames(dropEls); this.attributesToElements = attributesToElements; namespaceContext = new DelegatingNamespaceContext( writer.getNamespaceContext(), nsMap); this.defaultNamespace = defaultNamespace; }
Example 2
Source File: DOMUtil.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 3
Source File: DOMUtil.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 4
Source File: SourceUtils.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 5
Source File: DOMUtil.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 6
Source File: SourceUtils.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 7
Source File: DOMUtil.java From hottub with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 8
Source File: IdentityrefXmlCodec.java From yangtools with Eclipse Public License 1.0 | 5 votes |
@Override public void writeValue(final XMLStreamWriter ctx, final QName value) throws XMLStreamException { final RandomPrefix prefixes = new RandomPrefix(ctx.getNamespaceContext()); final String str = QNameCodecUtil.encodeQName(value, uri -> prefixes.encodePrefix(uri.getNamespace())); for (Entry<URI, String> e : prefixes.getPrefixes()) { ctx.writeNamespace(e.getValue(), e.getKey().toString()); } ctx.writeCharacters(str); }
Example 9
Source File: Uml2XsdWriter.java From secure-data-service with Apache License 2.0 | 5 votes |
private static final String typeLexicalName(final QName name, final XMLStreamWriter context) { final NamespaceContext namespaceContext = context.getNamespaceContext(); final String namespace = name.getNamespaceURI(); if (namespace.length() > 0) { final String prefix = namespaceContext.getPrefix(namespace); if (prefix == null || prefix.length() == 0) { return name.getLocalPart(); } else { return prefix.concat(":").concat(name.getLocalPart()); } } else { return name.getLocalPart(); } }
Example 10
Source File: DOMUtil.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 11
Source File: Uml2XsdPluginWriterAdapter.java From secure-data-service with Apache License 2.0 | 5 votes |
private static final String typeLexicalName(final QName name, final XMLStreamWriter context) { final NamespaceContext namespaceContext = context.getNamespaceContext(); final String namespace = name.getNamespaceURI(); if (namespace.length() > 0) { final String prefix = namespaceContext.getPrefix(namespace); if (prefix.length() > 0) { return prefix.concat(":").concat(name.getLocalPart()); } else { return name.getLocalPart(); } } else { return name.getLocalPart(); } }
Example 12
Source File: SourceUtils.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 13
Source File: DOMUtil.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 14
Source File: SourceUtils.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 15
Source File: DOMUtil.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 16
Source File: SourceUtils.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 17
Source File: DOMUtil.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
private static boolean isPrefixDeclared(XMLStreamWriter writer, String nsUri, String prefix) { boolean prefixDecl = false; NamespaceContext nscontext = writer.getNamespaceContext(); Iterator prefixItr = nscontext.getPrefixes(nsUri); while (prefixItr.hasNext()) { if (prefix.equals(prefixItr.next())) { prefixDecl = true; break; } } return prefixDecl; }
Example 18
Source File: SourceUtils.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 19
Source File: SourceUtils.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** * sets undeclared prefixes on the writer * @param prefix * @param writer * @throws XMLStreamException */ private static void setUndeclaredPrefix(String prefix, String readerURI, XMLStreamWriter writer) throws XMLStreamException { String writerURI = null; if (writer.getNamespaceContext() != null) { writerURI = writer.getNamespaceContext().getNamespaceURI(prefix); } if (writerURI == null) { writer.setPrefix(prefix, readerURI != null ? readerURI : ""); writer.writeNamespace(prefix, readerURI != null ? readerURI : ""); } }
Example 20
Source File: StreamWriterFacade.java From yangtools with Eclipse Public License 1.0 | 4 votes |
StreamWriterFacade(final XMLStreamWriter writer) { this.writer = requireNonNull(writer); prefixes = new RandomPrefix(writer.getNamespaceContext()); }