Java Code Examples for javax.xml.namespace.NamespaceContext#getPrefix()
The following examples show how to use
javax.xml.namespace.NamespaceContext#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: StAXPostInitAction.java From openjdk-8 with GNU General Public License v2.0 | 6 votes |
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } }
Example 2
Source File: StAXPostInitAction.java From TencentKona-8 with GNU General Public License v2.0 | 6 votes |
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } }
Example 3
Source File: StAXPostInitAction.java From openjdk-8-source with GNU General Public License v2.0 | 6 votes |
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } }
Example 4
Source File: TransformingNamespacesTest.java From sis with Apache License 2.0 | 6 votes |
/** * Tests {@link TransformingNamespaces#getPrefix(String)}. */ @Test public void testGetPrefix() { final NamespaceContext fns = TransformingNamespaces.asXML(this, TransformVersion.ISO19139); /* * Following tests are not really interesting since TransformingNamespaces, * after failing to find a mapping, just delegates to this.getPrefix(…). */ assertEquals("cit", fns.getPrefix(Namespaces.CIT)); assertEquals("mdb", fns.getPrefix(Namespaces.MDB)); assertEquals("gex", fns.getPrefix(Namespaces.GEX)); /* * This is the interesting test: TransformingNamespaces replaces the gmd namespace * by one of the namespace recognized by this NamespaceContext, then delegates. */ assertNull(getPrefix(LegacyNamespaces.GMD)); // This test is useless if this is non-null. final String prefix = fns.getPrefix(LegacyNamespaces.GMD); assertTrue(prefix, prefixes().contains(prefix)); }
Example 5
Source File: StAXPostInitAction.java From openjdk-jdk8u with GNU General Public License v2.0 | 6 votes |
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } }
Example 6
Source File: StAXPostInitAction.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 6 votes |
public void run() { NamespaceContext ns = nsc; if(xsw!=null) ns = xsw.getNamespaceContext(); if(xew!=null) ns = xew.getNamespaceContext(); // StAX javadoc isn't very clear on the behavior, // so work defensively in anticipation of broken implementations. if(ns==null) return; // we can't enumerate all the in-scope namespace bindings in StAX, // so we only look for the known static namespace URIs. // this is less than ideal, but better than nothing. for( String nsUri : serializer.grammar.nameList.namespaceURIs ) { String p = ns.getPrefix(nsUri); if(p!=null) serializer.addInscopeBinding(nsUri,p); } }
Example 7
Source File: DatatypeConverterImpl.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 8
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 9
Source File: CompoundNamespaceContext.java From rice with Educational Community License v2.0 | 5 votes |
/** * @see javax.xml.namespace.NamespaceContext#getPrefix(java.lang.String) */ public String getPrefix(String namespaceURI) { if (namespaceURI == null) { throw new IllegalArgumentException("The namespace uri cannot be null."); } for (NamespaceContext nc: contexts) { String prefix = nc.getPrefix(namespaceURI); if (prefix != null) { return prefix; } } return null; }
Example 10
Source File: DatatypeConverterImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 11
Source File: DatatypeConverterImpl.java From openjdk-8 with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 12
Source File: DatatypeConverterImpl.java From openjdk-jdk9 with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 13
Source File: DatatypeConverterImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 14
Source File: DatatypeConverterImpl.java From openjdk-jdk8u-backup with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 15
Source File: DatatypeConverterImpl.java From jdk1.8-source-analysis with Apache License 2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 16
Source File: DatatypeConverterImpl.java From JDKSourceCode1.8 with MIT License | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 17
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 18
Source File: DatatypeConverterImpl.java From jdk8u60 with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 19
Source File: DatatypeConverterImpl.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
public static String _printQName(QName val, NamespaceContext nsc) { // Double-check String qname; String prefix = nsc.getPrefix(val.getNamespaceURI()); String localPart = val.getLocalPart(); if (prefix == null || prefix.length() == 0) { // be defensive qname = localPart; } else { qname = prefix + ':' + localPart; } return qname; }
Example 20
Source File: XmlEntryDeserializer.java From olingo-odata2 with Apache License 2.0 | 4 votes |
private void readCustomElement(final XMLStreamReader reader, final String tagName, //NOSONAR final EntityInfoAggregator eia, final DeserializerProperties readProperties) throws EdmException, EntityProviderException, XMLStreamException { //NOSONAR EntityPropertyInfo targetPathInfo = eia.getTargetPathInfo(tagName); NamespaceContext nsctx = reader.getNamespaceContext(); boolean skipTag = true; if (!Edm.NAMESPACE_ATOM_2005.equals(reader.getName().getNamespaceURI())) { if (targetPathInfo != null) { final String customPrefix = targetPathInfo.getCustomMapping().getFcNsPrefix(); final String customNamespaceURI = targetPathInfo.getCustomMapping().getFcNsUri(); if (customPrefix != null && customNamespaceURI != null) { String xmlPrefix = nsctx.getPrefix(customNamespaceURI); String xmlNamespaceUri = reader.getNamespaceURI(customPrefix); if (customNamespaceURI.equals(xmlNamespaceUri) && customPrefix.equals(xmlPrefix)) { //NOSONAR skipTag = false; reader.require(XMLStreamConstants.START_ELEMENT, customNamespaceURI, tagName); final String text = reader.getElementText(); reader.require(XMLStreamConstants.END_ELEMENT, customNamespaceURI, tagName); final EntityPropertyInfo propertyInfo = getValidatedPropertyInfo(eia, tagName); final Class<?> typeMapping = typeMappings.getMappingClass(propertyInfo.getName()); final EdmSimpleType type = (EdmSimpleType) propertyInfo.getType(); final Object value = type.valueOfString(text, EdmLiteralKind.DEFAULT, readProperties == null || readProperties.isValidatingFacets() ? propertyInfo.getFacets() : null, typeMapping == null ? type.getDefaultType() : typeMapping); properties.put(tagName, value); } } } else { throw new EntityProviderException(EntityProviderException.INVALID_PROPERTY.addContent(tagName)); } } if (skipTag) { skipStartedTag(reader); } }