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();
}
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();
}
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;
}
}
}
}
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);
}
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;
}
Aggregations