Example usage for javax.xml.namespace QName getNamespaceURI

List of usage examples for javax.xml.namespace QName getNamespaceURI

Introduction

In this page you can find the example usage for javax.xml.namespace QName getNamespaceURI.

Prototype

public String getNamespaceURI() 

Source Link

Document

Get the Namespace URI of this QName.

Usage

From source file:com.evolveum.midpoint.model.common.expression.script.xpath.ReflectionXPathFunctionResolver.java

@Override
public XPathFunction resolveFunction(QName functionQName, int arity) {
    boolean enableDebug = false;
    String namespace = functionQName.getNamespaceURI();
    if (StringUtils.isEmpty(namespace)) {
        namespace = MidPointConstants.NS_FUNC_BASIC;
        enableDebug = true;/*from   w w w  .j  a  v a2s . c  om*/
    } else if (namespace.equals(MidPointConstants.NS_FUNC_BASIC)) {
        enableDebug = true;
    }

    FunctionLibrary lib = findLibrary(namespace);
    if (lib == null) {
        LOGGER.trace("Unknown namespace for function {} function with {} arguments", functionQName, arity);
        return null;
    }

    Object functionObject = null;
    if (lib.getXmlFunctions() != null) {
        functionObject = lib.getXmlFunctions();
    } else {
        functionObject = lib.getGenericFunctions();
    }

    String functionName = functionQName.getLocalPart();

    LOGGER.trace("Resolving to {} function with {} arguments", functionName, arity);
    ReflectionXPathFunctionWrapper xPathFunction = new ReflectionXPathFunctionWrapper(functionObject,
            functionName, arity, enableDebug);
    return xPathFunction;
}

From source file:com.evolveum.midpoint.web.component.input.QNameChoiceRenderer.java

@Override
public Object getDisplayValue(QName object) {
    StringBuilder sb = new StringBuilder();
    if (usePrefix) {
        String prefix = prefixMap.get(object.getNamespaceURI());
        if (StringUtils.isNotBlank(prefix)) {
            sb.append(prefix);//www . ja va 2 s  .co m
        }
    }

    sb.append(object.getLocalPart());
    return sb.toString();
}

From source file:com.evolveum.midpoint.prism.xml.XmlTypeConverter.java

/**
 * @param val//from   ww  w  .  ja v  a 2  s . c  om
 * @param elementName
 * @param doc
 * @param recordType
 * @return created element
 * @throws JAXBException
 */
public static Object toXsdElement(Object val, QName elementName, Document doc, boolean recordType)
        throws SchemaException {
    if (val == null) {
        // if no value is specified, do not create element
        return null;
    }
    Class type = XsdTypeMapper.getTypeFromClass(val.getClass());
    if (type == null) {
        throw new IllegalArgumentException(
                "No type mapping for conversion: " + val.getClass() + "(element " + elementName + ")");
    }
    if (doc == null) {
        doc = DOMUtil.getDocument();
    }
    Element element = doc.createElementNS(elementName.getNamespaceURI(), elementName.getLocalPart());
    //TODO: switch to global namespace prefixes map
    //            element.setPrefix(MidPointNamespacePrefixMapper.getPreferredPrefix(elementName.getNamespaceURI()));
    toXsdElement(val, element, recordType);
    return element;
}

From source file:io.twipple.springframework.data.clusterpoint.convert.DefaultClusterpointTypeMapperTest.java

@Test
public void testWriteType() throws Exception {
    ClusterpointDocument document = new ClusterpointDocument();
    mapper.writeType(MockEntity.class, document);

    QName typeAlias = document.getTypeAlias();
    assertNotNull(typeAlias);//from w  w w .  j  a v  a2 s  . c o  m
    assertEquals("urn:io-twipple-springframework-data-clusterpoint-convert", typeAlias.getNamespaceURI());
    assertEquals("MockEntity", typeAlias.getLocalPart());
    assertEquals("mock", typeAlias.getPrefix());
}

From source file:com.vistatec.ocelot.xliff.okapi.OkapiXLIFFFactory.java

private boolean isXliffVersionAttributeName(QName name) {
    if (!"version".equals(name.getLocalPart()))
        return false;
    String ns = name.getNamespaceURI();
    return (ns == null || "".equals(ns) || "urn:oasis:names:tc:xliff:document:1.2".equals(ns)
            || "urn:oasis:names:tc:xliff:document:2.0".equals(ns));
}

From source file:com.bradmcevoy.http.webdav.PropFindXmlGeneratorHelper.java

/**
 *
 * @param propFindResponses/*w ww  .j  a va2 s .  co  m*/
 * @return - map where key is the uri, and value is the prefix
 */
Map<String, String> findNameSpaces(List<PropFindResponse> propFindResponses) {
    int i = 1;
    Map<String, String> map = new HashMap<String, String>();
    // always add webdav namespace
    map.put(WebDavProtocol.NS_DAV.getName(), WebDavProtocol.NS_DAV.getPrefix());
    // Hack for caldav!!! Temporary only!!!
    //xmlns:cal="urn:ietf:params:xml:ns:caldav" xmlns:cs="http://calendarserver.org/ns/"
    map.put("urn:ietf:params:xml:ns:caldav", "cal");
    map.put("http://calendarserver.org/ns/", "cs");
    map.put("urn:ietf:params:xml:ns:carddav", "card");
    for (PropFindResponse r : propFindResponses) {
        for (QName p : r.getKnownProperties().keySet()) {
            String uri = p.getNamespaceURI();
            //                    if( uri.endsWith( ":" ) ) uri = uri.substring( 0, uri.length() - 1 ); // strip trailing :
            if (!map.containsKey(uri)) {
                map.put(uri, "ns" + i++);
            }
        }
    }
    return map;
}

From source file:com.bradmcevoy.http.webdav.PropFindXmlGeneratorHelper.java

private void sendErrorProperties(Response.Status status, XmlWriter writer, Map<String, String> mapOfNamespaces,
        List<NameAndError> properties) {
    //            log.debug( "sendUnknownProperties: " + properties.size() );
    if (!properties.isEmpty()) {
        XmlWriter.Element elPropStat = writer.begin(WebDavProtocol.NS_DAV.getPrefix(), "propstat").open();
        XmlWriter.Element elProp = writer.begin(WebDavProtocol.NS_DAV.getPrefix(), "prop").open();
        for (NameAndError ne : properties) {
            QName qname = ne.getName();
            String prefix = mapOfNamespaces.get(qname.getNamespaceURI());
            writer.writeProperty(prefix, qname.getLocalPart());
        }//from w  ww.j a va 2 s  .c  om
        elProp.close();
        writer.writeProperty(WebDavProtocol.NS_DAV.getPrefix(), "status", status.toString());
        elPropStat.close();
    }
}

From source file:com.evolveum.midpoint.web.util.SchrodingerComponentInitListener.java

private String qnameToString(QName qname) {
    if (qname == null) {
        return null;
    }/*w ww  . ja v  a 2s  .  c  om*/

    return StringUtils.join(new Object[] { qname.getNamespaceURI(), qname.getLocalPart() }, "#");
}

From source file:com.bradmcevoy.http.webdav.PropFindXmlGeneratorHelper.java

private void sendProperties(Response.Status status, XmlWriter writer, Map<String, String> mapOfNamespaces,
        Map<QName, ValueAndType> properties, String href) {
    if (!properties.isEmpty()) {
        XmlWriter.Element elPropStat = writer.begin(WebDavProtocol.NS_DAV.getPrefix(), "propstat").open();
        XmlWriter.Element elProp = writer.begin(WebDavProtocol.NS_DAV.getPrefix(), "prop").open();
        for (QName qname : properties.keySet()) {
            String prefix = mapOfNamespaces.get(qname.getNamespaceURI());
            ValueAndType val = properties.get(qname);
            valueWriters.writeValue(writer, qname, prefix, val, href, mapOfNamespaces);
        }/*from ww  w.  ja va  2s.  c  o  m*/
        elProp.close();
        writer.writeProperty(WebDavProtocol.NS_DAV.getPrefix(), "status", status.toString());
        elPropStat.close();
    }
}

From source file:com.evolveum.midpoint.prism.xml.GlobalDynamicNamespacePrefixMapper.java

@Override
public QName setQNamePrefix(QName qname) {
    String namespace = qname.getNamespaceURI();
    String prefix = getPrefix(namespace);
    if (prefix == null) {
        return qname;
    }//from  www .ja v  a2s. co m
    return new QName(qname.getNamespaceURI(), qname.getLocalPart(), prefix);
}