Example usage for javax.xml XMLConstants NULL_NS_URI

List of usage examples for javax.xml XMLConstants NULL_NS_URI

Introduction

In this page you can find the example usage for javax.xml XMLConstants NULL_NS_URI.

Prototype

String NULL_NS_URI

To view the source code for javax.xml XMLConstants NULL_NS_URI.

Click Source Link

Document

Namespace URI to use to represent that there is no Namespace.

Usage

From source file:org.kalypsodeegree_impl.model.feature.FeatureHelper.java

/**
 * Returns the property of a feature.<br>
 * If the given qname contains no namespace (), it returns the first property with the same localPart.
 *///from  ww w . j a  v a  2  s . c  o m
public static Object getPropertyLax(final Feature feature, final QName property) {
    final IPropertyType pt = feature.getFeatureType().getProperty(property);
    if (pt != null)
        return feature.getProperty(pt);

    if (XMLConstants.NULL_NS_URI.equals(property.getNamespaceURI()))
        return feature.getProperty(property.getLocalPart());

    // Will throw an IllegalArgumentException as the property will not be found
    return feature.getProperty(property);
}

From source file:org.kalypsodeegree_impl.model.feature.FeatureHelper.java

/**
 * Returns all feature with the given local typename.
 *///from  w w w  .j a  va 2  s. c om
public static Feature[] getFeaturesWithLocalName(final GMLWorkspace workspace, final String typenameLocalPart) {
    final QNameUnique localTypename = QNameUnique.create(XMLConstants.NULL_NS_URI, typenameLocalPart);

    final FeatureTypeFilter predicate = new FeatureTypeFilter(null, localTypename, false);

    return getFeatures(workspace, predicate);
}

From source file:org.kalypsodeegree_impl.model.feature.gmlxpath.GMLXPathSegment.java

public static GMLXPathSegment forQName(final QName qname) {
    final String namespaceURI = qname.getNamespaceURI();
    final String localPart = qname.getLocalPart();

    if (XMLConstants.NULL_NS_URI.equals(namespaceURI))
        return new GMLXPathSegment(localPart, null);

    final String defaultPrefix = "ns" + System.currentTimeMillis();
    // Hopefully this works allways...
    final String prefix = NSUtilities.getNSProvider().getPreferredPrefix(namespaceURI, defaultPrefix);

    // Create a constant context
    final NamespaceContext namespaceContext = new NamespaceContext() {
        @Override//  w ww . ja v  a2 s. c  om
        public String getNamespaceURI(final String pref) {
            return namespaceURI;
        }

        @Override
        public String getPrefix(final String namespace) {
            return prefix;
        }

        @Override
        public Iterator<String> getPrefixes(final String namespace) {
            throw new UnsupportedOperationException();
        }
    };

    final String segment = String.format("%s:%s", prefix, localPart);
    return new GMLXPathSegment(segment, namespaceContext);
}

From source file:org.kuali.rice.kew.engine.node.hierarchyrouting.HierarchyRoutingNode.java

/**
 * Loads hierarchy provider class via the GlobalResourceLoader
 * @param nodeInstance the current RouteNodeInstance
 * @param context the current RouteContext
 * @return the HierarchyProvider implementation, as specified by the HIERARCHY_PROVIDER config parameter
 *//*ww w .j a va  2 s .c o  m*/
protected HierarchyProvider getHierarchyProvider(RouteNodeInstance nodeInstance, RouteContext context) {
    Map<String, String> cfgMap = Utilities
            .getKeyValueCollectionAsMap(nodeInstance.getRouteNode().getConfigParams());
    String hierarchyProviderClass = cfgMap.get(HIERARCHY_PROVIDER);
    if (StringUtils.isEmpty(hierarchyProviderClass)) {
        throw new WorkflowRuntimeException(
                "hierarchyProvider configuration parameter not set for HierarchyRoutingNode: "
                        + nodeInstance.getName());
    }
    QName qn = QName.valueOf(hierarchyProviderClass);
    ObjectDefinition od;
    if (XMLConstants.NULL_NS_URI.equals(qn.getNamespaceURI())) {
        od = new ObjectDefinition(qn.getLocalPart());
    } else {
        od = new ObjectDefinition(qn.getLocalPart(), qn.getNamespaceURI());
    }
    HierarchyProvider hp = (HierarchyProvider) GlobalResourceLoader.getObject(od);
    hp.init(nodeInstance, context);
    return hp;
}

From source file:org.lockss.util.OneToOneNamespaceContext.java

/**
 * <p>// w w  w .j  av  a 2s .c om
 * Builds a new instance that initially maps
 * {@link XMLConstants#DEFAULT_NS_PREFIX} to {@link XMLConstants#NULL_NS_URI}.
 * </p>
 * 
 * @since 1.67.5
 */
public OneToOneNamespaceContext() {
    this.bidiMap = new DualHashBidiMap<String, String>();
    put(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI);
}

From source file:org.lockss.util.OneToOneNamespaceContext.java

/**
 * <p>//from ww  w  .jav a2 s . c o  m
 * Builds a new instance that initially has the same mappings as the given
 * map, and adds a mapping from {@link XMLConstants#DEFAULT_NS_PREFIX} to
 * {@link XMLConstants#NULL_NS_URI} if there is no mapping for it initially.
 * </p>
 * 
 * @param map
 *          An initial mapping of prefixes to namespace URIs.
 * @since 1.67.5
 */
public OneToOneNamespaceContext(Map<String, String> map) {
    this.bidiMap = new DualHashBidiMap<String, String>(map);
    if (!bidiMap.containsKey(XMLConstants.DEFAULT_NS_PREFIX)) {
        put(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI);
    }
}

From source file:org.mcisb.util.xml.XmlWriter.java

/**
 * //from  w ww  . jav a 2 s.  c  om
 * @param name
 * @throws XMLStreamException
 */
public void writeEndElement(final String name) throws XMLStreamException {
    writeEndElement(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI, name);
}

From source file:org.mcisb.util.xml.XmlWriter.java

/**
 * /*from   ww  w . jav  a2  s .  c om*/
 * @param name
 * @param attributesMap
 * @throws XMLStreamException
 */
protected void writeStartElement(final String name, final Map<String, String> attributesMap)
        throws XMLStreamException {
    writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, XMLConstants.NULL_NS_URI, name, attributesMap);
}

From source file:org.milyn.edisax.EDIParser.java

public void endElement(String elementName, String namespace, boolean indent) throws SAXException {
    indentDepth.value--;//  w ww .ja  v a  2s.co m
    if (indent) {
        indent();
    }
    if (XMLConstants.NULL_NS_URI.equals(namespace)) {
        // No namespace support
        contentHandler.endElement(NULL_NS_URI, elementName, elementName);
    } else {
        // With namespace support
        String alias = getNamespaceAlias(namespace);
        nsStack.pop();
        contentHandler.endElement(namespace, elementName, alias + ":" + elementName);
    }
}

From source file:org.talend.commons.runtime.xml.XPathPrefixHandler.java

/**
 * DOC chuang Comment method "getNamespace".
 * //from   w ww. j av  a  2  s  .  c  o  m
 * @param node
 * @param parentPath
 * @return
 */
private void computeNamespace(NodeInfo info, String parentPath) {
    Node node = info.node;
    List<Node> attributes = new ArrayList<Node>();
    // return node.getNamespaceURI();
    String defaultNamespace = null;
    if (isXSDFile) {
        if (node.getNodeName().equals("xs:attribute")) { //$NON-NLS-1$
            attributes.add(node);
        }
    }
    NamedNodeMap nodeMap = node.getAttributes();
    for (int i = 0; i < nodeMap.getLength(); i++) {
        Node attr = nodeMap.item(i);
        String attrName = attr.getNodeName();
        boolean isPrefix = attrName.startsWith(XMLConstants.XMLNS_ATTRIBUTE)
                && (!isXSDFile || !attrName.equals("xmlns:xs")); //$NON-NLS-1$
        if (isPrefix) {
            if (attrName.length() == XMLConstants.XMLNS_ATTRIBUTE.length()) {
                defaultNamespace = attr.getNodeValue();
                namespaceContext.addNamespaceURI(XMLConstants.NULL_NS_URI, attr.getNodeValue());
            } else {
                int index = attrName.indexOf(':');
                String prefix = attrName.substring(index + 1);
                namespaceContext.addNamespaceURI(prefix, attr.getNodeValue());
            }
        } else if (!isXSDFile) {
            attributes.add(attr);
        }
    }

    if (defaultNamespace != null) {
        info.defaultNamespace = defaultNamespace;
    } else {
        // same as parent
        if (parentPath.equals("")) { //$NON-NLS-1$
            // no namespace
            info.defaultNamespace = ""; //$NON-NLS-1$
        } else {
            info.defaultNamespace = pathNodesMap.get(parentPath).defaultNamespace;
        }
    }

    String part[] = node.getNodeName().split(":"); //$NON-NLS-1$
    if (part.length > 1) {
        info.namespace = namespaceContext.getNamespaceURI(part[0]);
    } else {
        info.namespace = info.defaultNamespace;
    }

    collectAttributes(info, attributes);
}