Package org.eclipse.wst.xml.core.internal.provisional.document

Examples of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument


      // some problem occurred, abort
      if (xmlModel == null)
        return;
     
      try {
        IDOMDocument document = xmlModel.getDocument();

        // store the text in a byte array; make a full copy to ease
        // any threading problems
        byte[] byteArray;
        try {
View Full Code Here


    ElementImpl impl = (ElementImpl) element;

    if (impl.isJSPTag()) {
      // check if JSP content type and JSP Document
      IDOMDocument document = (IDOMDocument) element.getOwnerDocument();
      if (document != null && document.isJSPType()) {
        if (document.isJSPDocument() && !impl.hasChildNodes()) {
          impl.setJSPTag(false);
        }
      } else {
        impl.setJSPTag(false);
      }
View Full Code Here

                .getModelForRead(
                    (IStructuredDocument) textViewer
                        .getDocument());
          }
          if (sModel != null) {
            IDOMDocument docNode = ((IDOMModel) sModel)
                .getDocument();
            contentAssistRequest = new ContentAssistRequest(
                docNode, docNode, sdRegion, completionRegion,
                documentPosition, 0, null);
            addEmptyDocumentProposals(contentAssistRequest, context);
View Full Code Here

    boolean acceptAmpersand = false;
    boolean acceptEntityRef = true;
    boolean acceptJSPEnd = true;
    String endTagName = null;
    if (this.node.getNodeType() == Node.ATTRIBUTE_NODE) {
      IDOMDocument document = (IDOMDocument) this.node.getOwnerDocument();
      if (document != null && document.isJSPType())
        acceptTag = true;
      if (acceptTag) {
        Attr attr = (Attr) this.node;
        ElementImpl element = (ElementImpl) attr.getOwnerElement();
        if (element != null && element.isJSPTag())
          acceptTag = false;
      }
      // if the source does not include single quote,
      // double quote is valid
      acceptQuote = (source.indexOf('\'') < 0);
    } else if (this.node.getNodeType() == Node.TEXT_NODE) {
      TextImpl text = (TextImpl) this.node;
      if (text.isJSPContent()) {
        int index = source.indexOf(JSPTag.TAG_CLOSE);
        if (index < 0)
          return source;
        acceptTag = true;
        acceptClose = true;
        acceptQuote = true;
        acceptAmpersand = true;
        acceptJSPEnd = false;
      } else if (text.isCDATAContent()) {
        endTagName = text.getParentNode().getNodeName();
        if (endTagName == null)
          return null; // error
        acceptTag = true;
        acceptClose = true;
        acceptQuote = true;
        acceptAmpersand = true;
      }
    } else {
      IDOMDocument document = null;
      if (this.node.getNodeType() == Node.DOCUMENT_NODE) {
        document = (IDOMDocument) this.node;
      } else {
        document = (IDOMDocument) this.node.getOwnerDocument();
      }
      if (document != null && document.isJSPType())
        acceptTag = true;
    }

    StringBuffer buffer = null;
    int copiedLength = 0;
View Full Code Here

    boolean acceptClose = false;
    boolean acceptQuote = true;
    boolean acceptEntityRef = true;
    String endTagName = null;
    if (this.node.getNodeType() == Node.ATTRIBUTE_NODE) {
      IDOMDocument document = (IDOMDocument) this.node.getOwnerDocument();
      if (document != null && document.isJSPType())
        acceptTag = true;
      if (acceptTag) {
        Attr attr = (Attr) this.node;
        ElementImpl element = (ElementImpl) attr.getOwnerElement();
        if (element != null && element.isJSPTag())
          acceptTag = false;
      }
      // if the source does not include single quote,
      // double quote is valid
      acceptQuote = (source.indexOf('\'') < 0);
    } else if (this.node.getNodeType() == Node.TEXT_NODE) {
      TextImpl text = (TextImpl) this.node;
      if (text.isJSPContent()) {
        int index = source.indexOf(JSPTag.TAG_CLOSE);
        if (index < 0)
          return true;
        message = XMLCoreMessages.Invalid_character_gt_fo_ERROR_;
        throw new InvalidCharacterException(message, '>', index + 1);
      } else if (text.isCDATAContent()) {
        endTagName = text.getParentNode().getNodeName();
        if (endTagName == null)
          return false; // error
        acceptTag = true;
        acceptClose = true;
      } else if(hasNestedRegion(text)) {
        //there are cases (such as with EL) that the text is to complicated
        //  to be verified by this validator
        return true;
      }
    } else {
      IDOMDocument document = null;
      if (this.node.getNodeType() == Node.DOCUMENT_NODE) {
        document = (IDOMDocument) this.node;
      } else {
        document = (IDOMDocument) this.node.getOwnerDocument();
      }
      if (document != null && document.isJSPType())
        acceptTag = true;
    }

    char c = 0;
    int length = source.length();
View Full Code Here

    try {
      IProject prj = StructuredModelUtil.getProjectFor(part.getIDOMNode()
          .getModel());
      PageExpressionContext.initialize(prj);

      IDOMDocument doc = (IDOMDocument) part.getIDOMNode();
      Object obj = doc.getAdapterFor(IDocumentPageVariableAdapter.class);
      if (obj instanceof IPageVariablesProvider) {
        ((IPageVariablesProvider) obj).refresh();
        PageExpressionContext.getCurrent().pushPageVarProvider(
            (IPageVariablesProvider) obj);
      } else {
        PageExpressionContext.getCurrent().pushPageVarProvider(null);
      }

      // IDOMModel previewModel =
      // (IDOMModel)StructuredModelManager.getModelManager().createNewInstance(doc.getModel());
      // IDOMDocument previewDoc = previewModel.getDocument();

      // CR400625: creating XML model here instead of HTML model. Since
      // for HTML model, there are checking enforced
      // by WTP to make sure the HTML content model is not invalidated.
      // And sometimes, the converted HTML may not fully
      // comply with HTML content model.
      // Use XML instead to workaround the content model validation.

      // CR403449: But if we use XML, then system can't recogonize special
      // tag such as "script", "style", they
      // support <!-- --> in them.
      // So we are still using HTML model, but in TagConverter, we are
      // always caling DOMUtil.cloneNodeDeepIgnoreError
      // to try to skip the errors.
      // Hopefully in later version of SSE, the famous "br" problem is
      // fixed, and we won't met error when doing
      // deep clone.
      // IStructuredModel sModel =
      // StructuredModelManager.getModelManager().createUnManagedStructuredModelFor(IContentTypeIdentifier.ContentTypeID_XML);
      // FIXME: if is not jsp, should use original contentType, if is jsp,
      // should use the corresponding
      // content type
      IStructuredModel sModel = StructuredModelManager.getModelManager()
          .createUnManagedStructuredModelFor(
              ContentTypeIdForHTML.ContentTypeID_HTML);

      IDOMDocument previewDoc = ((IDOMModel) sModel).getDocument();
      PreviewConvertContext context = new PreviewConvertContext(
          previewDoc);

      ISourceGenerator generator = XMLGeneratorImpl.getInstance();
      List subeditparts = part.getChildren();
View Full Code Here

   * Gets the IDOMDocument instance on which new Nodes are created.
   *
   * @return IDOMDocument instance.
   */
  public IDOMDocument getDestDocument() {
    IDOMDocument document = null;
    if (destDocument != null) {
      document = destDocument;
    } else {
      document = (IDOMDocument)hostElement.getOwnerDocument();
    }
View Full Code Here

    try {

      xmlModel = (IDOMModel) StructuredModelManager.getModelManager().getModelForRead(
          file);
      if (xmlModel != null) {
        IDOMDocument doc = xmlModel.getDocument();

        // XXX: need to also register page variable adapters. In the
        // future, this should go to some
        // SSE system registry mechanism.
        xmlModel.getFactoryRegistry().addFactory(
            new PageVariableAdapterFactory());
        provider = new DocumentPageVariableAdapter(doc);
        doc.addAdapter(provider);

        provider.refresh();
        PageExpressionContext.getCurrent()
            .pushPageVarProvider(provider);
View Full Code Here

  }

  /**
   */
  private void documentTypeChanged() {
    IDOMDocument document = getDocument();
    if (document == null)
      return; // error
    IDOMModel model = document.getModel();
    if (model == null)
      return; // error

    IFile file = getFile(model);

    // find DOCTYPE delcaration and Public ID
    String publicId = null;
    String systemId = null;
    DocumentType newDocumentType = findDocumentType(document);
    if (newDocumentType != null) {
      publicId = newDocumentType.getPublicId();
      systemId = newDocumentType.getSystemId();
    }
    else {
      // lookup default set by contentsettings
      publicId = HTMLContentProperties.getProperty(HTMLContentProperties.DOCUMENT_TYPE, file, true);
    }

    // lookup DOCTYPE registry
    HTMLDocumentTypeEntry newEntry = null;
    if (publicId != null) {
      newEntry = HTMLDocumentTypeRegistry.getInstance().getEntry(publicId);
    }
    else if (systemId == null){
      if (newDocumentType != null){ // <!DOCTYPE html>
        newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_HTML5);
      }
    }

    boolean newXMLType = (newEntry != null ? newEntry.isXMLType() : false);
    boolean newWMLType = (newEntry != null ? newEntry.isWMLType() : false);

    if (!newXMLType) {
      // find XML declaration
      if (findXMLNode(document) != null) {
        newXMLType = true;
      }

      // check file extension
      if (file != null) {
        String ext = file.getFileExtension();
        if (ext != null && ext.equalsIgnoreCase(XHTML)) {
          newXMLType = true;
        }

        if (ext != null && ext.equalsIgnoreCase(WML)) {
          newXMLType = true;
          newWMLType = true;
        }
      }

    }

    if (newEntry == null) {
      // lookup system default
      if (newXMLType && newDocumentType == null) {
        // use default XHTML, if it's XML and no document type
        // declared
        if (newWMLType)
          newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_WML);
        else
          newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_XHTML);

      }
      else {
        newEntry = HTMLDocumentTypeRegistry.getInstance().getDefaultEntry(HTMLDocumentTypeRegistry.DEFAULT_HTML);
      }
      if (newEntry == null)
        return; // error
    }

    if (newDocumentType == null) {
      DocumentType oldDocumentType = getDocumentType();
      if (oldDocumentType == null || oldDocumentType.getName() != newEntry.getName()) {
        // create implicit DocumentType
        DOMImplementation impl = document.getImplementation();
        if (impl != null) {
          String name = newEntry.getName();
          publicId = newEntry.getPublicId();
          systemId = newEntry.getSystemId();
          newDocumentType = impl.createDocumentType(name, publicId, systemId);
View Full Code Here

    Element root = document.getDocumentElement();
    return root != null && (root.hasAttribute(XMLNS_JSP) || HTTP_JAVA_SUN_COM_JSP_PAGE.equals(root.getAttribute(XMLNS)));
  }

  private void validate(IFile file, int kind, ValidationState state, IProgressMonitor monitor, IDOMModel model, IReporter reporter) {
    IDOMDocument document = model.getDocument();
    if (document == null)
      return; // error

    boolean isXMLJSP = isXMLJSP(document);
    boolean hasHTMLFeature = hasHTMLFeature(document);
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.provisional.document.IDOMDocument

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.