Java Code Examples for javax.xml.stream.events.Namespace#getPrefix()
The following examples show how to use
javax.xml.stream.events.Namespace#getPrefix() .
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: MergedNsContext.java From woodstox with Apache License 2.0 | 6 votes |
private Map<String,Namespace> buildByPrefixMap() { int len = mNamespaces.size(); if (len == 0) { return Collections.emptyMap(); } LinkedHashMap<String,Namespace> m = new LinkedHashMap<String,Namespace>(1 + len + (len>>1)); for (int i = 0; i < len; ++i) { Namespace ns = mNamespaces.get(i); String prefix = ns.getPrefix(); if (prefix == null) { // shouldn't happen but... prefix = ""; } m.put(prefix, ns); } return m; }
Example 2
Source File: StAXSchemaParser.java From hottub with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 3
Source File: CorbaStreamReader.java From cxf with Apache License 2.0 | 5 votes |
public String getNamespacePrefix(int arg0) { List<Namespace> namespaces = eventProducer.getNamespaces(); if (namespaces == null) { return null; } Namespace ns = namespaces.get(arg0); if (ns != null) { return ns.getPrefix(); } return null; }
Example 4
Source File: MergedNsContext.java From woodstox with Apache License 2.0 | 5 votes |
@Override public Iterator<String> doGetPrefixes(String nsURI) { // Note: base class checks for 'known' problems and prefixes: ArrayList<String> l = null; for (int i = 0, len = mNamespaces.size(); i < len; ++i) { Namespace ns = mNamespaces.get(i); String uri = ns.getNamespaceURI(); if (uri == null) { uri = ""; } if (uri.equals(nsURI)) { if (l == null) { l = new ArrayList<String>(); } String prefix = ns.getPrefix(); l.add((prefix == null) ? "" : prefix); } } if (mParentCtxt != null) { @SuppressWarnings("unchecked") Iterator<String> it = /*(Iterator<String>)*/mParentCtxt.getPrefixes(nsURI); if (l == null) { return it; } while (it.hasNext()) { l.add(it.next()); } } if (l == null) { return DataUtil.emptyIterator(); } return l.iterator(); }
Example 5
Source File: MergedNsContext.java From woodstox with Apache License 2.0 | 5 votes |
@Override public String doGetPrefix(String nsURI) { // Note: base class checks for 'known' problems and prefixes: if (mNsByURI == null) { mNsByURI = buildByNsURIMap(); } Namespace ns = mNsByURI.get(nsURI); if (ns == null && mParentCtxt != null) { return mParentCtxt.getPrefix(nsURI); } return (ns == null) ? null : ns.getPrefix(); }
Example 6
Source File: StAXSchemaParser.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 7
Source File: StAXSchemaParser.java From openjdk-8-source with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 8
Source File: StAXSchemaParser.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 9
Source File: StAXSchemaParser.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 10
Source File: StAXSchemaParser.java From Bytecoder with Apache License 2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator<Namespace> namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 11
Source File: StAXSchemaParser.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 12
Source File: StAXSchemaParser.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 13
Source File: StAXSchemaParser.java From JDKSourceCode1.8 with MIT License | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 14
Source File: StAXSchemaParser.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 15
Source File: StAXSchemaParser.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
/** Fills in the list of declared prefixes. */ private void fillDeclaredPrefixes(Iterator namespaces) { fDeclaredPrefixes.clear(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); fDeclaredPrefixes.add(prefix != null ? prefix : ""); } }
Example 16
Source File: XMLProtocol.java From ts-reaktive with MIT License | 4 votes |
/** * Combines a Namespace and local name into a QName. */ public static QName qname(Namespace ns, String name) { return new QName(ns.getNamespaceURI(), name, ns.getPrefix()); }
Example 17
Source File: AbstractXMLEventWriter.java From jettison with Apache License 2.0 | 4 votes |
public void add(XMLEvent event) throws XMLStreamException { if (event.isStartDocument()) { streamWriter.writeStartDocument(); } else if (event.isStartElement()) { StartElement element = event.asStartElement(); QName elQName = element.getName(); if (elQName.getPrefix().length() > 0 && elQName.getNamespaceURI().length() > 0) streamWriter.writeStartElement(elQName.getPrefix(), elQName .getLocalPart(), elQName.getNamespaceURI()); else if (elQName.getNamespaceURI().length() > 0) streamWriter.writeStartElement(elQName.getNamespaceURI(), elQName.getLocalPart()); else streamWriter.writeStartElement(elQName.getLocalPart()); // Add element namespaces Iterator namespaces = element.getNamespaces(); while (namespaces.hasNext()) { Namespace ns = (Namespace) namespaces.next(); String prefix = ns.getPrefix(); String nsURI = ns.getNamespaceURI(); streamWriter.writeNamespace(prefix, nsURI); } // Add element attributes Iterator attris = element.getAttributes(); while (attris.hasNext()) { Attribute attr = (Attribute) attris.next(); QName atQName = attr.getName(); String value = attr.getValue(); if (atQName.getPrefix().length() > 0 && atQName.getNamespaceURI().length() > 0) streamWriter.writeAttribute(atQName.getPrefix(), atQName .getNamespaceURI(), atQName.getLocalPart(), value); else if (atQName.getNamespaceURI().length() > 0) streamWriter.writeAttribute(atQName.getNamespaceURI(), atQName.getLocalPart(), value); else streamWriter.writeAttribute(atQName.getLocalPart(), value); } } else if (event.isCharacters()) { Characters chars = event.asCharacters(); streamWriter.writeCharacters(chars.getData()); } else if (event.isEndElement()) { streamWriter.writeEndElement(); } else if (event.isEndDocument()) { streamWriter.writeEndDocument(); } else { throw new XMLStreamException("Unsupported event type: " + event); } }