Package org.eclipse.wst.xml.core.internal.contentmodel

Examples of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument


  }   

     
  public CMDocument getCMDocument(Element element, String uri)
  {
    CMDocument result = null;
    NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument());
    namespaceTable.addElementLineage(element);
    NamespaceInfo namespaceInfo = namespaceTable.getNamespaceInfoForURI(uri);
    if (namespaceInfo != null)
    {
View Full Code Here


    String[] doctypeInfo = getDoctypeInfo(document);
    if (doctypeInfo != null)
    {  
      // we have detected doctype information so we assume that we can locate the CMElementDeclaration
      // in the CMDocument's table of global elements
      CMDocument cmDocument = getCorrespondingCMDocument(element, false);

      // TODO... consider replacing above with
      // CMDocument cmDocument = getCMDocument(document, doctypeInfo[0], doctypeInfo[1]);

      if (cmDocument != null)
      {       
        result = (CMElementDeclaration)cmDocument.getElements().getNamedItem(element.getNodeName());   
                
        // this is a hack to get our xsl code assist working... we might want to handle similar
        // grammar behaviour via some established model query setting
        if (result == null && getImplictDoctype(document) != null)
        {        
          Node parent = element.getParentNode();
          if (parent != null && parent.getNodeType() == Node.ELEMENT_NODE)
          {
            result = getCMElementDeclaration((Element)parent);
          }
        }
      }
    }   
    else
   
      // here we use a namespaceTable to consider if the root element has any namespace information
      //
      NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument());
      List list = NamespaceTable.getElementLineage(element);
      Element rootElement = (Element)list.get(0);
      namespaceTable.addElement(rootElement);
        
      if (namespaceTable.isNamespaceEncountered())
      {                                        
        // we assume that this is an XMLSchema style namespace aware document
        result = getCMElementDeclaration(element, list, namespaceTable);
      }
      else
      {
        result = checkExternalSchema(element);
        if (result == null) {
        // we assume that this is an inferred CMDocument for a DTD style 'namespaceless' document
            CMDocument cmDocument = getCMDocument("", "", "DTD"); //$NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          if (cmDocument != null) {
          result = (CMElementDeclaration)cmDocument.getElements().getNamedItem(element.getNodeName());
        }
        }
      }
    }            
    return result;
View Full Code Here

          ed = (CMElementDeclaration)currentED.getLocalElements().getNamedItem(nodeName);
        }
                                                                  
        if (ed == null)
        {              
            CMDocument cmDocument = getCMDocument(publicId, systemId, "XSD"); //$NON-NLS-1$
            if (cmDocument != null)
            {
              ed = (CMElementDeclaration)cmDocument.getElements().getNamedItem(nodeName);  
            }                                       
        }                                                  
        currentED = ed;    
      }                                      
    }
View Full Code Here

        if (ed == null)
        {              
          NamespaceInfo namespaceInfo = namespaceTable.getNamespaceInfoForPrefix(prefix);                  
          if (namespaceInfo != null)
          {
            CMDocument cmDocument = getCMDocument(namespaceInfo.uri, namespaceInfo.locationHint, "XSD"); //$NON-NLS-1$
            if (cmDocument != null)
            {
              ed = (CMElementDeclaration)cmDocument.getElements().getNamedItem(unprefixedName);  
            }                                       
          }
        }                                                  
        currentED = ed;    
View Full Code Here

    }
    return reg;
  }

  private void registerHTMLCategory() {
    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.HTML_DOC_TYPE);
  }
View Full Code Here

    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.HTML_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.HTML_DOC_TYPE);
  }

  private void registerJSPCategory() {
    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.JSP11_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.JSP11_DOC_TYPE);
  }
View Full Code Here

    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.JSP11_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.JSP11_DOC_TYPE);
  }
 
  private void registerTapestryCategory(){
    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.TAPESTRY5_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.TAPESTRY5_DOC_TYPE);
  }
View Full Code Here

    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.TAPESTRY5_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.TAPESTRY5_DOC_TYPE);
  }
 
  private void registerTapestryCustomActionCategory(){
    final CMDocument doc = HTMLCMDocumentFactory.getCMDocument(CMDocType.TAPESTRY5_CUSTOM_DOC_TYPE);
    _paletteHelper.getOrCreateTaglibPaletteDrawer(this, doc, CMDocType.TAPESTRY5_CUSTOM_DOC_TYPE);
  }
View Full Code Here

    int min = Math.max(anyElement.getMinOccur(), forcedMin);
    alwaysVisit = false;

    String uri = anyElement.getNamespaceURI();
    String targetNSProperty = "http://org.eclipse.wst/cm/properties/targetNamespaceURI"; //$NON-NLS-1$
    CMDocument parentCMDocument = (CMDocument) anyElement.getProperty("CMDocument"); //$NON-NLS-1$
    CMElementDeclaration ed = null;

    // System.out.println("parentCMDocument = " + parentCMDocument);
    // //$NON-NLS-1$
    if (parentCMDocument != null) {
      if (uri == null || uri.startsWith("##") || uri.equals(parentCMDocument.getProperty(targetNSProperty))) //$NON-NLS-1$
      {
        ed = getSuitableElement(getParentCMElementDeclaration(), parentCMDocument);
      }
    }


    if (ed == null && externalCMDocumentSupport != null && uri != null && !uri.startsWith("##") && currentParent instanceof Element) //$NON-NLS-1$
    {
      CMDocument externalCMDocument = externalCMDocumentSupport.getCMDocument((Element) currentParent, uri);
      if (externalCMDocument != null) {
        ed = getSuitableElement(null, externalCMDocument);
      }
    }
View Full Code Here

    }
  }

  public static void testPopulateDocumentFromGrammarFile(Document document, String grammarFileName, String rootElementName, boolean hack) {
    try {
      CMDocument cmDocument = ContentModelManager.getInstance().createCMDocument(grammarFileName, null);
      CMNamedNodeMap elementMap = cmDocument.getElements();
      CMElementDeclaration element = (CMElementDeclaration) elementMap.getNamedItem(rootElementName);

      DOMContentBuilderImpl contentBuilder = new DOMContentBuilderImpl(document);
      contentBuilder.supressCreationOfDoctypeAndXMLDeclaration = hack;
      contentBuilder.createDefaultRootContent(cmDocument, element);
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.CMDocument

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.