Example usage for javax.xml XMLConstants DEFAULT_NS_PREFIX

List of usage examples for javax.xml XMLConstants DEFAULT_NS_PREFIX

Introduction

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

Prototype

String DEFAULT_NS_PREFIX

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

Click Source Link

Document

Prefix to use to represent the default XML Namespace.

Usage

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

/**
 * <p>/*from w w  w.  j a  v  a2  s  . c  o  m*/
 * 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  a 2 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

/**
 * //  w w w  .ja v a2  s .c o  m
 * @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  w  w  w .j av a  2s  .c o  m*/
 * @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.opencastproject.mediapackage.XMLCatalogImpl.java

/**
 * Splits a QName into its parts.//w  ww  . j  av a  2 s .  co  m
 * 
 * @param qName
 *          the qname to split
 * @return an array of prefix (0) and local part (1). The prefix is "" if the qname belongs to the default namespace.
 */
private String[] splitQName(String qName) {
    String[] parts = qName.split(":", 3);
    if (parts.length > 2)
        throw new IllegalArgumentException("Local name must not contain ':'");
    if (parts.length == 2)
        return parts;
    return new String[] { XMLConstants.DEFAULT_NS_PREFIX, parts[0] };
}

From source file:org.opencastproject.mediapackage.XMLCatalogImpl.java

/**
 * Returns a "prefixed name" consisting of namespace prefix and local name.
 * /*from  ww w  .j  a v a  2 s .  c om*/
 * @param prefix
 *          the namespace prefix, may be <code>null</code>
 * @param localName
 *          the local name
 * @return the "prefixed name" <code>prefix:localName</code>
 */
private String toQName(String prefix, String localName) {
    StringBuilder b = new StringBuilder();
    if (prefix != null && !XMLConstants.DEFAULT_NS_PREFIX.equals(prefix)) {
        b.append(prefix);
        b.append(":");
    }
    b.append(localName);
    return b.toString();
}

From source file:org.opencastproject.metadata.dublincore.DublinCoreCatalogImpl.java

/**
 * Creates a new dublin core metadata container.
 * /*from w  w  w.ja  v  a2  s .  c o m*/
 * @param id
 *          the element identifier withing the package
 * @param uri
 *          the document location
 * @param size
 *          the catalog size in bytes
 * @param checksum
 *          the catalog checksum
 */
protected DublinCoreCatalogImpl(String id, URI uri, MediaPackageElementFlavor flavor, long size,
        Checksum checksum) {
    super(id, flavor, uri, size, checksum, MimeTypes.XML);
    bindings.bindPrefix(XMLConstants.DEFAULT_NS_PREFIX, OPENCASTPROJECT_DUBLIN_CORE_NS_URI);
    bindings.bindPrefix("xsi", XMLConstants.W3C_XML_SCHEMA_INSTANCE_NS_URI);
    bindings.bindPrefix("dc", ELEMENTS_1_1_NS_URI);
    bindings.bindPrefix("dcterms", TERMS_NS_URI);
    bindings.bindPrefix("oc", OC_NS_URI);
}

From source file:org.opencastproject.metadata.dublincore.DublinCores.java

/**
 * Create a new empty Opencast DublinCore metadata catalog with
 * {@link org.opencastproject.mediapackage.MediaPackageElements#EPISODE} flavor.
 * Register all necessary namespaces and set the root tag to
 * {@link #OC_DC_CATALOG_ROOT_ELEMENT}.//from ww w  .  j a  va 2 s. c  om
 */
@Nonnull
public static DublinCoreCatalog mkOpencast() {
    final DublinCoreCatalog dc = new DublinCoreCatalog();
    dc.setFlavor(MediaPackageElements.EPISODE);
    dc.addBindings(XmlNamespaceContext.mk(XmlNamespaceBinding.mk(ELEMENTS_1_1_NS_PREFIX, ELEMENTS_1_1_NS_URI),
            XmlNamespaceBinding.mk(TERMS_NS_PREFIX, TERMS_NS_URI),
            // Opencast property namespace
            XmlNamespaceBinding.mk(OC_PROPERTY_NS_PREFIX, OC_PROPERTY_NS_URI),
            // Opencast root tag
            XmlNamespaceBinding.mk(XMLConstants.DEFAULT_NS_PREFIX, OC_DC_CATALOG_NS_URI)));
    dc.setRootTag(OC_DC_CATALOG_ROOT_ELEMENT);
    return dc;
}

From source file:org.wso2.carbon.humantask.core.api.rendering.NamespaceResolver.java

public String getNamespaceURI(String prefix) {
    if (prefix.equals(XMLConstants.DEFAULT_NS_PREFIX)) {
        return refDomDocument.lookupNamespaceURI(null);
    } else {// w ww.jav  a2  s.  c o m
        return refDomDocument.lookupNamespaceURI(prefix);
    }
}

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;
    }/*  ww w. j a v  a  2s.  c o 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);
}