Search in sources :

Example 11 with QName

use of org.exist.dom.QName in project exist by eXist-db.

the class InMemoryXMLStreamReader method getNamespacePrefix.

@Override
public String getNamespacePrefix(final int index) {
    if (index > getNamespaceCount()) {
        throw new ArrayIndexOutOfBoundsException();
    }
    final int ns = doc.alphaLen[currentNode];
    final QName nsQName = doc.namespaceCode[ns + index];
    return nsQName.getLocalPart();
}
Also used : QName(org.exist.dom.QName)

Example 12 with QName

use of org.exist.dom.QName in project exist by eXist-db.

the class InMemoryXMLStreamReader method getNamespaceURI.

@Override
public String getNamespaceURI(final int index) {
    if (index > getNamespaceCount()) {
        throw new ArrayIndexOutOfBoundsException();
    }
    final int ns = doc.alphaLen[currentNode];
    final QName nsQName = doc.namespaceCode[ns + index];
    return nsQName.getNamespaceURI();
}
Also used : QName(org.exist.dom.QName)

Example 13 with QName

use of org.exist.dom.QName in project exist by eXist-db.

the class DocumentImpl method endNode.

private void endNode(final NodeImpl node, final Receiver receiver) throws SAXException {
    if (node.getNodeType() == Node.ELEMENT_NODE) {
        receiver.endElement(node.getQName());
        // End all prefix mappings used for the element
        final int nr = node.nodeNumber;
        int ns = document.alphaLen[nr];
        if (ns > -1) {
            while ((ns < document.nextNamespace) && (document.namespaceParent[ns] == nr)) {
                final QName nsQName = document.namespaceCode[ns];
                if (XMLConstants.XMLNS_ATTRIBUTE.equals(nsQName.getLocalPart())) {
                    receiver.endPrefixMapping(XMLConstants.DEFAULT_NS_PREFIX);
                } else {
                    receiver.endPrefixMapping(nsQName.getLocalPart());
                }
                ++ns;
            }
        }
    }
}
Also used : QName(org.exist.dom.QName)

Example 14 with QName

use of org.exist.dom.QName in project exist by eXist-db.

the class MemTreeBuilder method startElement.

/**
 * Create a new element.
 *
 * @param namespaceURI DOCUMENT ME!
 * @param localName    DOCUMENT ME!
 * @param qname        DOCUMENT ME!
 * @param attributes   DOCUMENT ME!
 * @return the node number of the created element
 */
public int startElement(final String namespaceURI, String localName, final String qname, final Attributes attributes) {
    final int prefixIdx = qname.indexOf(':');
    String prefix = null;
    if (context != null && !getDefaultNamespace().equals(namespaceURI == null ? XMLConstants.NULL_NS_URI : namespaceURI)) {
        prefix = context.getPrefixForURI(namespaceURI);
    }
    if (prefix == null) {
        prefix = (prefixIdx != Constants.STRING_NOT_FOUND) ? qname.substring(0, prefixIdx) : null;
    }
    if (localName.isEmpty()) {
        if (prefixIdx > -1) {
            localName = qname.substring(prefixIdx + 1);
        } else {
            localName = qname;
        }
    }
    final QName qn = new QName(localName, namespaceURI, prefix);
    return startElement(qn, attributes);
}
Also used : QName(org.exist.dom.QName)

Example 15 with QName

use of org.exist.dom.QName in project exist by eXist-db.

the class MemTreeBuilder method processingInstruction.

public int processingInstruction(final String target, final String data) {
    final QName qname = new QName(target, null, null);
    final int nodeNr = doc.addNode(Node.PROCESSING_INSTRUCTION_NODE, level, qname);
    doc.addChars(nodeNr, (data == null) ? "" : data);
    linkNode(nodeNr);
    return nodeNr;
}
Also used : QName(org.exist.dom.QName)

Aggregations

QName (org.exist.dom.QName)260 Test (org.junit.Test)54 Sequence (org.exist.xquery.value.Sequence)39 DBBroker (org.exist.storage.DBBroker)31 MemTreeBuilder (org.exist.dom.memtree.MemTreeBuilder)28 IOException (java.io.IOException)23 Document (org.w3c.dom.Document)23 DocumentSet (org.exist.dom.persistent.DocumentSet)20 Text (org.w3c.dom.Text)20 NameTest (org.exist.xquery.NameTest)17 XPathException (org.exist.xquery.XPathException)17 BrokerPool (org.exist.storage.BrokerPool)15 IllegalQNameException (org.exist.dom.QName.IllegalQNameException)13 Node (org.w3c.dom.Node)12 ReentrantLock (java.util.concurrent.locks.ReentrantLock)11 NodeSet (org.exist.dom.persistent.NodeSet)11 SAXException (org.xml.sax.SAXException)11 DefaultDocumentSet (org.exist.dom.persistent.DefaultDocumentSet)10 MutableDocumentSet (org.exist.dom.persistent.MutableDocumentSet)10 PermissionDeniedException (org.exist.security.PermissionDeniedException)10