Package org.exist.dom

Examples of org.exist.dom.AttrImpl


            case Node.ELEMENT_NODE:
                return new ElementImpl();
            case Node.TEXT_NODE:
                return new TextImpl();
            case Node.ATTRIBUTE_NODE:
                return new AttrImpl();
            case Node.CDATA_SECTION_NODE:
              return new CDATASectionImpl();
            case Node.PROCESSING_INSTRUCTION_NODE:
                return new ProcessingInstructionImpl();
            case Node.COMMENT_NODE:
View Full Code Here


            AttrList attribs;
            for (int i = 0; i < nodes.length; i++) {
                switch (nodes[i].nodeType) {
                    case XMLStreamReader.ATTRIBUTE:
                        attribs = new AttrList();
                        AttrImpl attr = (AttrImpl) broker.objectWith(otherDoc, nodes[i].nodeId);
                        attribs.addAttribute(new QName(attr.getLocalName(), attr.getNamespaceURI(), attr.getPrefix()),
                                attr.getValue(), attr.getType());
                        handler.startElement(ELEMENT_ATTRIBUTE, attribs);
                        handler.endElement(ELEMENT_ATTRIBUTE);
                        break;
                    case XMLStreamReader.START_ELEMENT:
                        // check if there's a complete element to write, not just a start or end tag
View Full Code Here

            final StoredNode ql[] = selectAndLock(transaction);
            final IndexListener listener = new IndexListener(ql);
            final NotificationService notifier = broker.getBrokerPool().getNotificationService();
            Node temp;
            TextImpl text;
            AttrImpl attribute;
            ElementImpl parent;
            for (int i = 0; i < ql.length; i++) {
                final StoredNode node = ql[i];
                if (node == null) {
                    LOG.warn("select " + selectStmt + " returned empty node set");
                    continue;
                }
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                doc.getMetadata().setIndexListener(listener);
                if (!doc.getPermissions().validate(broker.getSubject(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + broker.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                }
                parent = (ElementImpl) node.getParentStoredNode();
                if (parent == null)
                    {throw new EXistException("The root element of a document can not be replaced with 'xu:replace'. " +
                        "Please consider removing the document or use 'xu:update' to just replace the children of the root.");}
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
                        if (modifications == 0) {modifications = 1;}
                        temp = children.item(0);
                        parent.replaceChild(transaction, temp, node);
                        break;
                    case Node.TEXT_NODE:
                        temp = children.item(0);
                        text = new TextImpl(temp.getNodeValue());
                        modifications = 1;
                        text.setOwnerDocument(doc);
                        parent.updateChild(transaction, node, text);
                        break;
                    case Node.ATTRIBUTE_NODE:
                        final AttrImpl attr = (AttrImpl) node;
                        temp = children.item(0);
                        attribute = new AttrImpl(attr.getQName(), temp.getNodeValue(), broker.getBrokerPool().getSymbols());
                        attribute.setOwnerDocument(doc);
                        parent.updateChild(transaction, node, attribute);
                        break;
                    default:
                        throw new EXistException("unsupported node-type");
View Full Code Here

                        newElem.setNodeName(new QName(newName, "", null));
                        parent.updateChild(transaction, node, newElem);
                        modificationCount++;
                        break;
                    case Node.ATTRIBUTE_NODE:
                        final AttrImpl newAttr = new AttrImpl((AttrImpl) node);
                        newAttr.setNodeName(new QName(newName, "", null));
                        parent.updateChild(transaction, node, newAttr);
                        modificationCount++;
                        break;
                    default:
                        throw new EXistException("unsupported node-type");
View Full Code Here

                        StoredNode child = (StoredNode) insertedNode.getFirstChild();
                        while (child != null) {
                            if (StandardDiff.NAMESPACE.equals(child.getNamespaceURI()) && "attribute".equals(child.getLocalName())) {
                                NamedNodeMap map = child.getAttributes();
                                for (int j = 0; j < map.getLength(); j++) {
                                    AttrImpl attr = (AttrImpl) map.item(j);
                                    if (!attr.getName().startsWith("xmlns"))
                                        attrs.addAttribute(attr.getQName(), attr.getValue(),
                                                attr.getType(), attr.getNodeId());
                                }
                            }
                            child = (StoredNode) child.getNextSibling();
                        }
                    }
View Full Code Here

                {--attrLength;}
            else {
                p = attrQName.indexOf(':');
                attrPrefix = (p != Constants.STRING_NOT_FOUND) ?
                    attrQName.substring(0, p) : null;
                final AttrImpl attr = (AttrImpl) NodePool.getInstance().borrowNode(Node.ATTRIBUTE_NODE);
                final QName attrQN = broker.getBrokerPool().getSymbols().getQName(Node.ATTRIBUTE_NODE, attrNS, attrLocalName, attrPrefix);
                try {
                    attr.setNodeName(attrQN, broker.getBrokerPool().getSymbols());
                } catch (DOMException e) {
                    throw new SAXException(e.getMessage(), e);
                }
                attr.setValue(attributes.getValue(i));
                attr.setOwnerDocument(document);
                if (attributes.getType(i).equals(ATTR_ID_TYPE)) {
                    attr.setType(AttrImpl.ID);
                } else if (attributes.getType(i).equals(ATTR_IDREF_TYPE)) {
                    attr.setType(AttrImpl.IDREF);
                } else if (attributes.getType(i).equals(ATTR_IDREFS_TYPE)) {
                    attr.setType(AttrImpl.IDREFS);
                } else if (attr.getQName().equalsSimple(Namespaces.XML_ID_QNAME)) {
                    // an xml:id attribute. Normalize the attribute and set its
                    // type to ID
                    attr.setValue(StringValue.trimWhitespace(StringValue
                            .collapseWhitespace(attr.getValue())));
                    if (!XMLChar.isValidNCName(attr.getValue()))
                        {throw new SAXException(
                            "Value of xml:id attribute is not a valid NCName: "
                            + attr.getValue());}
                    attr.setType(AttrImpl.ID);
                } else if (attr.getQName().equalsSimple(Namespaces.XML_SPACE_QNAME)) {
                    node.setPreserveSpace("preserve".equals(attr.getValue()));
                }
                node.appendChildInternal(prevNode, attr);
                setPrevious(attr);
                if (!validate) {
                    broker.storeNode(transaction, attr, currentPath, indexSpec);
View Full Code Here

          final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();

                final StoredNode ql[] = selectAndLock(transaction, inSeq);
                final IndexListener listener = new IndexListener(ql);
                TextImpl text;
                AttrImpl attribute;
                ElementImpl parent;
                for (int i = 0; i < ql.length; i++) {
                    final StoredNode node = ql[i];
                    final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                    if (!doc.getPermissions().validate(context.getUser(),
                            Permission.WRITE)){
                            throw new XPathException(this, "User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                    }
                    doc.getMetadata().setIndexListener(listener);
                                       
                    //update the document
                    switch (node.getNodeType())
                    {
                        case Node.ELEMENT_NODE:
                final NodeListImpl content = new NodeListImpl();
                for (final SequenceIterator j = contentSeq.iterate(); j.hasNext(); ) {
                  final Item next = j.nextItem();
                  if (Type.subTypeOf(next.getType(), Type.NODE))
                    {content.add(((NodeValue)next).getNode());}
                  else {
                    text = new TextImpl(next.getStringValue());
                    content.add(text);
                  }
                }
                            ((ElementImpl) node).update(transaction, content);
                            break;
                        case Node.TEXT_NODE:
                            parent = (ElementImpl) node.getParentNode();
                          text = new TextImpl(contentSeq.getStringValue());
                            text.setOwnerDocument(doc);
                            parent.updateChild(transaction, node, text);
                            break;
                        case Node.ATTRIBUTE_NODE:
                            parent = (ElementImpl) node.getParentNode();
                            if (parent == null) {
                                LOG.warn("parent node not found for "
                                        + node.getNodeId());
                                break;
                            }
                            final AttrImpl attr = (AttrImpl) node;
                            attribute = new AttrImpl(attr.getQName(), contentSeq.getStringValue(), context.getBroker().getBrokerPool().getSymbols());
                            attribute.setOwnerDocument(doc);
                            parent.updateChild(transaction, node, attribute);
                            break;
                        default:
                            throw new XPathException(this, "unsupported node-type");
View Full Code Here

            final StoredNode ql[] = selectAndLock(transaction, inSeq);
            final IndexListener listener = new IndexListener(ql);
            final NotificationService notifier = context.getBroker().getBrokerPool().getNotificationService();
            Item temp;
            TextImpl text;
            AttrImpl attribute;
            ElementImpl parent;
            for (int i = 0; i < ql.length; i++) {
                final StoredNode node = ql[i];
                final DocumentImpl doc = (DocumentImpl)node.getOwnerDocument();
                if (!doc.getPermissions().validate(context.getUser(), Permission.WRITE)) {
                        throw new PermissionDeniedException("User '" + context.getSubject().getName() + "' does not have permission to write to the document '" + doc.getDocumentURI() + "'!");
                }
                doc.getMetadata().setIndexListener(listener);
               
                //update the document
                parent = (ElementImpl) node.getParentStoredNode();
                if (parent == null)
                    {throw new XPathException(this, "The root element of a document can not be replaced with 'update replace'. " +
                            "Please consider removing the document or use 'update value' to just replace the children of the root.");}
                switch (node.getNodeType()) {
                    case Node.ELEMENT_NODE:
                        temp = contentSeq.itemAt(0);
            if (!Type.subTypeOf(temp.getType(), Type.NODE))
              {throw new XPathException(this,
                  Messages.getMessage(Error.UPDATE_REPLACE_ELEM_TYPE,
                      Type.getTypeName(temp.getType())));}
                        parent.replaceChild(transaction, ((NodeValue)temp).getNode(), node);
                        break;
                    case Node.TEXT_NODE:
                        text = new TextImpl(contentSeq.getStringValue());
                        text.setOwnerDocument(doc);
                        parent.updateChild(transaction, node, text);
                        break;
                    case Node.ATTRIBUTE_NODE:
                        final AttrImpl attr = (AttrImpl) node;
                        attribute = new AttrImpl(attr.getQName(), contentSeq.getStringValue(), context.getBroker().getBrokerPool().getSymbols());
                        attribute.setOwnerDocument(doc);
                        parent.updateChild(transaction, node, attribute);
                        break;
                    default:
                        throw new EXistException("unsupported node-type");
View Full Code Here

                            final ElementImpl newElem = new ElementImpl((ElementImpl) node);
                            newElem.setNodeName(newQName, context.getBroker().getBrokerPool().getSymbols());
                            parent.updateChild(transaction, node, newElem);
                            break;
                        case Node.ATTRIBUTE_NODE:
                            final AttrImpl newAttr = new AttrImpl((AttrImpl) node);
                            newAttr.setNodeName(newQName, context.getBroker().getBrokerPool().getSymbols());
                            parent.updateChild(transaction, node, newAttr);
                            break;
                        default:
                            throw new XPathException(this, "unsupported node-type");
                    }
View Full Code Here

TOP

Related Classes of org.exist.dom.AttrImpl

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.