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.wso2.carbon.sequences.ui.util.ns.QNameFactory.java

public QName createQName(String id, String localName, HttpSession httpSession) {

    if (!assertIDNotEmpty(id) || !assertLocalNameNotEmpty(localName)) {
        return null;
    }/* w w w.j  a  v  a 2 s  .  co  m*/

    NameSpacesInformationRepository repository = (NameSpacesInformationRepository) httpSession
            .getAttribute(NameSpacesInformationRepository.NAMESPACES_INFORMATION_REPOSITORY);
    if (repository == null) {
        return new QName(localName);
    }

    NameSpacesInformation information = repository
            .getNameSpacesInformation(SequenceEditorHelper.getEditingMediatorPosition(httpSession), id);
    if (information == null) {
        return new QName(localName);
    }
    if (log.isDebugEnabled()) {
        log.debug("Getting NameSpaces :" + information + " for id :" + id);
    }

    Iterator<String> iterator = information.getPrefixes();
    if (iterator.hasNext()) {
        String prefix = iterator.next();
        String uri = information.getNameSpaceURI(prefix);
        if (uri == null) {
            uri = XMLConstants.NULL_NS_URI;
        }
        if (prefix == null) {
            prefix = XMLConstants.DEFAULT_NS_PREFIX;
        }
        return new QName(uri, localName, prefix);
    }
    information.removeAllNameSpaces();
    return new QName(localName);
}

From source file:org.xchain.framework.jxpath.JXPathValidator.java

static void validatePrefix(String prefix, NamespaceContext xmlns) {
    if ((prefix != null) && (!XMLConstants.DEFAULT_NS_PREFIX.equals(prefix))
            && XMLConstants.NULL_NS_URI.equals(xmlns.getNamespaceURI(prefix))) {
        throw new JXPathException("The prefix '" + prefix + "' is not defined in the current context.");
    }//from   w  w w .  j  a  va 2 s . c  o  m
}

From source file:org.xchain.framework.util.JXPathContextUtil.java

public static void validate(String value, NamespaceContext namespaceContext) {
    Matcher matcher = uriLocalNamePattern.matcher(value);
    if (matcher.matches()) {
        // this is valid, so return.
        return;/*from   w  w  w . ja va  2s. c o m*/
    }

    matcher = prefixLocalNamePattern.matcher(value);
    if (matcher.matches()) {
        String prefix = matcher.group(1);

        if (prefix != null && !XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)
                && XMLConstants.NULL_NS_URI.equals(namespaceContext.getNamespaceURI(prefix))) {
            throw new JXPathException(
                    "There is not namespace mapping for the prefix of qname '" + value + "'.");
        }
        return;
    }

    matcher = localNamePattern.matcher(value);
    if (matcher.matches()) {
        return;
    }

    throw new JXPathException("There is a syntax error in the qname '" + value + "'.");
}

From source file:org.xchain.test.basic.TestBasic.java

@Test(expected = CommandNotFoundException.class)
public void testUnknownCommandLookup() throws Exception {
    QName name = new QName(XMLConstants.NULL_NS_URI, "Unknown");
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
    command = catalog.getCommand(name);/* w  w  w.j  a v  a2  s.  c  o m*/
}

From source file:org.xchain.test.basic.TestBasic.java

@Test
public void testCommandLookup() throws Exception {
    QName name = new QName(XMLConstants.NULL_NS_URI, COMMAND_NAME_1);
    catalog = CatalogFactory.getInstance().getCatalog(CATALOG_URI);
    command = catalog.getCommand(name);//from  www . j a v  a  2 s  .c o  m
    assertNotNull("Command is null.", command);
}

From source file:smartrics.rest.fitnesse.fixture.support.Tools.java

private static NamespaceContext toNsContext(final Map<String, String> ns) {
    NamespaceContext ctx = new NamespaceContext() {

        @Override//from w  w w  .  j a  v a  2s .co m
        public String getNamespaceURI(String prefix) {
            String u = ns.get(prefix);
            if (null == u) {
                return XMLConstants.NULL_NS_URI;
            }
            return u;
        }

        @Override
        public String getPrefix(String namespaceURI) {
            for (String k : ns.keySet()) {
                if (ns.get(k).equals(namespaceURI)) {
                    return k;
                }
            }
            return null;
        }

        @Override
        public Iterator<?> getPrefixes(String namespaceURI) {
            return null;
        }

    };
    return ctx;
}