code: @Override
      public long insertAttribute(final QName pQName, final String pValue) throws TTException {
          checkState(!mDelegate.isClosed(), "Transaction is already closed.");
          checkState(mDelegate.getCurrentNode() instanceof ElementNode,
              "Insert is not allowed if current node is not an ElementNode, but was %s", mDelegate
                  .getCurrentNode());
  
          final byte[] value = TypedValue.getBytes(pValue);
          final long elementKey = mDelegate.getCurrentNode().getDataKey();
  
          final int nameKey = insertName(buildName(pQName));
          final int namespaceKey = insertName(pQName.getNamespaceURI());
          final NodeDelegate nodeDel = new NodeDelegate(getPtx().incrementDataKey(), elementKey, 0);
          final NameNodeDelegate nameDel = new NameNodeDelegate(nodeDel, nameKey, namespaceKey);
          final ValNodeDelegate valDel = new ValNodeDelegate(nodeDel, value);
  
          final AttributeNode node = new AttributeNode(nodeDel, nameDel, valDel);
          getPtx().setData(node);
  
          final ITreeData parentNode = (org.treetank.data.interfaces.ITreeData)getPtx().getData(node.getParentKey());
          ((ElementNode)parentNode).insertAttribute(node.getDataKey());
          getPtx().setData(parentNode);
  
          mDelegate.setCurrentNode(node);
          adaptForInsert(node, false);
  
          adaptHashesWithAdd();
          return node.getDataKey();
  
      }
docs: {@inheritDoc}