/* (non-Javadoc)
   * @see com.siteview.mde.internal.core.text.DocumentHandler#getDocumentTextNode()
   */
  protected IDocumentTextNode getDocumentTextNode(String content, IDocumentElementNode parent) {

    IDocumentTextNode textNode = parent.getTextNode();
    if (textNode == null) {
      if (content.trim().length() > 0) {
        textNode = fFactory.createDocumentTextNode(content, parent);
      }
    } else {
      String newContent = textNode.getText() + content;
      textNode.setText(newContent);
    }
    return textNode;
  }
 /* (non-Javadoc)
  * @see org.eclipse.pde.internal.ui.model.plugin.DocumentHandler#getDocumentAttribute(java.lang.String, java.lang.String, org.eclipse.pde.internal.ui.model.IDocumentNode)
  */
 protected IDocumentAttributeNode getDocumentAttribute(
     String name, String value, IDocumentElementNode parent) {
   IDocumentAttributeNode attr = parent.getDocumentAttribute(name);
   try {
     if (attr == null) {
       attr = fFactory.createAttribute(name, value, parent);
     } else {
       if (!name.equals(attr.getAttributeName())) attr.setAttributeName(name);
       if (!value.equals(attr.getAttributeValue())) attr.setAttributeValue(value);
     }
   } catch (CoreException e) {
   }
   return attr;
 }
  /* (non-Javadoc)
   * @see org.eclipse.pde.internal.ui.model.plugin.DocumentHandler#getDocumentNode(java.lang.String, org.eclipse.pde.internal.ui.model.IDocumentNode)
   */
  protected IDocumentElementNode getDocumentNode(String name, IDocumentElementNode parent) {
    IDocumentElementNode node = null;
    if (parent == null) {
      node = getRootNode();
      if (node != null) {
        node.setOffset(-1);
        node.setLength(-1);
      }
    } else {
      IDocumentElementNode[] children = parent.getChildNodes();
      for (int i = 0; i < children.length; i++) {
        if (children[i].getOffset() < 0) {
          if (name.equals(children[i].getXMLTagName())) {
            node = children[i];
          }
          break;
        }
      }
    }

    if (node == null) return fFactory.createDocumentNode(name, parent);

    IDocumentAttributeNode[] attrs = node.getNodeAttributes();
    for (int i = 0; i < attrs.length; i++) {
      attrs[i].setNameOffset(-1);
      attrs[i].setNameLength(-1);
      attrs[i].setValueOffset(-1);
      attrs[i].setValueLength(-1);
    }

    for (int i = 0; i < node.getChildNodes().length; i++) {
      IDocumentElementNode child = node.getChildAt(i);
      child.setOffset(-1);
      child.setLength(-1);
    }

    // clear text nodes if the user is typing on the source page
    // they will be recreated in the characters() method
    if (isReconciling()) {
      node.removeTextNode();
      node.setIsErrorNode(false);
    }

    return node;
  }