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

Examples of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo


  public String computeErrorMessage(List namespaceInfoList, URIResolver idResolver) {
    String result = null;
    Hashtable prefixTable = new Hashtable();
    Hashtable uriTable = new Hashtable();
    for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext();) {
      NamespaceInfo nsInfo = (NamespaceInfo) iterator.next();
      nsInfo.normalize();

      String urikey = nsInfo.uri != null ? nsInfo.uri : ""; //$NON-NLS-1$
      NamespaceInfo nsInfo2 = null;
      if ((nsInfo2 = (NamespaceInfo) uriTable.get(urikey)) != null) {
        if ((nsInfo.uri != null) && nsInfo.uri.equals(nsInfo2.uri)) {
          result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_NAME + "'" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$
        }
        else {
          result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_NAME;
        }
        break;
      }
      else {
        uriTable.put(urikey, nsInfo);
      }

      if (nsInfo.uri != null) {
        String key = nsInfo.prefix != null ? nsInfo.prefix : ""; //$NON-NLS-1$
        if (prefixTable.get(key) != null) {
          if (nsInfo.prefix != null) {
            result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITH_PREFIX + "'" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$
            break;
          }
          else {
            result = XMLUIMessages._UI_WARNING_MORE_THAN_ONE_NS_WITHOUT_PREFIX;
            break;
          }
        }
        else {
          prefixTable.put(key, nsInfo);
        }

        if ((nsInfo.locationHint != null) && (idResolver != null)) {
          String grammarURI = idResolver.resolve(null, nsInfo.locationHint, nsInfo.locationHint);
          if (!URIHelper.isReadableURI(grammarURI, false)) {
            result = XMLUIMessages._UI_WARNING_SCHEMA_CAN_NOT_BE_LOCATED + " '" + nsInfo.locationHint + "'"; //$NON-NLS-1$ //$NON-NLS-2$
            break;
          }
        }
        if ((idResolver != null) && (nsInfo.locationHint == null) && !nsInfo.uri.equals(DOMNamespaceInfoManager.XSI_URI)) {
          result = XMLUIMessages._UI_WARNING_LOCATION_HINT_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$
          break;
        }
      }
      else {
        if (nsInfo.prefix != null) {
          result = XMLUIMessages._UI_WARNING_NAMESPACE_NAME_NOT_SPECIFIED + " '" + nsInfo.prefix + "'"; //$NON-NLS-1$ //$NON-NLS-2$
          break;
        }
      }
    }
    // additional tests
    if (result == null) {
      for (Iterator iterator = namespaceInfoList.iterator(); iterator.hasNext();) {
        NamespaceInfo nsInfo = (NamespaceInfo) iterator.next();
        nsInfo.normalize();
        if ((nsInfo.uri != null) && nsInfo.isPrefixRequired && (nsInfo.prefix == null)) {
          result = XMLUIMessages._UI_WARNING_PREFIX_NOT_SPECIFIED + " '" + nsInfo.uri + "'"; //$NON-NLS-1$ //$NON-NLS-2$
          break;
        }
      }
View Full Code Here


      CMDocument document = ContentModelManager.getInstance().createCMDocument(URIHelper.getURIForFilePath(grammarURI), "xsd"); //$NON-NLS-1$
      if(document != null) {
        List namespaceInfoList = (List) document.getProperty("http://org.eclipse.wst/cm/properties/namespaceInfo"); //$NON-NLS-1$
        if(namespaceInfoList != null) {
          NamespaceInfo info = (NamespaceInfo) namespaceInfoList.get(0);
          if(info != null) {
            if ((uriField.getText().trim().length() == 0) && (info.uri != null)) {
              uriField.setText(info.uri);
            }
            if ((prefixField.getText().trim().length() == 0) && (info.prefix != null)) {
View Full Code Here

      super.addElement(element)
      if (newNamespaceList != null)
      {
        for (Iterator i = newNamespaceList.iterator(); i.hasNext(); )
        {
          NamespaceInfo info = (NamespaceInfo)i.next();
          handleGrammar(info.uri, info.locationHint, "XSD"); //$NON-NLS-1$
        }
      }
    }                
View Full Code Here

        NamespaceTable namespaceTable = new NamespaceTable(element.getOwnerDocument());
        namespaceTable.addElementLineage(element);
        List list = namespaceTable.getNamespaceInfoList();
        for (Iterator i = list.iterator(); i.hasNext();)
        {
          NamespaceInfo info = (NamespaceInfo)i.next();
          if (info.uri != null && !info.uri.equals(excludedURI))
          {
            CMDocument document = xmlAssociationProvider.getCMDocument(info.uri, info.locationHint, "XSD"); //$NON-NLS-1$
            if (document != null)
            {
View Full Code Here

            generator.setDefaultSystemId(getDefaultSystemId());
            generator.createNamespaceInfoList();

            // Provide default namespace prefix if none
            for (int i = 0; i < generator.namespaceInfoList.size(); i++) {
              NamespaceInfo nsinfo = (NamespaceInfo) generator.namespaceInfoList.get(i);
              if (((nsinfo.prefix == null) || (nsinfo.prefix.trim().length() == 0)) && ((nsinfo.uri != null) && (nsinfo.uri.trim().length() != 0))) {
                nsinfo.prefix = getDefaultPrefix(generator.namespaceInfoList);
              }
            }
            xsdOptionsPanel.setNamespaceInfoList(generator.namespaceInfoList);
View Full Code Here

        return defaultPrefix;
      }

      Vector v = new Vector();
      for (int i = 0; i < nsInfoList.size(); i++) {
        NamespaceInfo nsinfo = (NamespaceInfo) nsInfoList.get(i);
        if (nsinfo.prefix != null) {
          v.addElement(nsinfo.prefix);
        }
      }
View Full Code Here

  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)
    {
      result = getCMDocument(namespaceInfo.uri, namespaceInfo.locationHint, "XSD"); //$NON-NLS-1$
    }
    return result;
View Full Code Here

          ed = (CMElementDeclaration)currentED.getLocalElements().getNamedItem(unprefixedName);
        }
                                                                  
        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)
            {
View Full Code Here

        addChildElementsToNamespaceTable(node, namespaceTable);
      }
      List list = namespaceTable.getNamespaceInfoList();
      for (Iterator i = list.iterator(); i.hasNext();)
      {
        NamespaceInfo info = (NamespaceInfo) i.next();   
        String uri = resolveGrammarURI(document, info.uri, info.locationHint);
        result.add(new CMDocumentReferenceImpl(info.uri, uri));
     
    }
    return result;
View Full Code Here

  protected void createAnyElementNode(CMAnyElement anyElement) {
    String uri = anyElement.getNamespaceURI();
    if ((uri != null) && !uri.startsWith("##")) //$NON-NLS-1$
    {
      if (table.get(uri) == null) {
        NamespaceInfo info = new NamespaceInfo();
        info.uri = uri;
        info.prefix = "p" + count++; //$NON-NLS-1$
        table.put(uri, info);
        list.add(info);
      }
View Full Code Here

TOP

Related Classes of org.eclipse.wst.xml.core.internal.contentmodel.util.NamespaceInfo

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.