Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
View | Details | Raw Unified | Return to bug 176416 | Differences between
and this patch

Collapse All | Expand All

(-)src-contentmodel/org/eclipse/wst/xsd/contentmodel/internal/XSDImpl.java (+55 lines)
Lines 82-87 Link Here
82
import org.w3c.dom.Node;
82
import org.w3c.dom.Node;
83
import org.w3c.dom.NodeList;
83
import org.w3c.dom.NodeList;
84
import org.w3c.dom.Text;
84
import org.w3c.dom.Text;
85
import org.w3c.dom.Document;
86
import org.w3c.dom.Attr;
87
import org.w3c.dom.NamedNodeMap;
85
88
86
/**
89
/**
87
 * Utility class to build cmnodes from XML Schema nodes. The XML Schema model is
90
 * Utility class to build cmnodes from XML Schema nodes. The XML Schema model is
Lines 881-886 Link Here
881
        info.isPrefixRequired = isPrefixRequired(xsdSchema);
884
        info.isPrefixRequired = isPrefixRequired(xsdSchema);
882
        list.add(info);
885
        list.add(info);
883
        getImportedNamespaceInfo(xsdSchema, list);
886
        getImportedNamespaceInfo(xsdSchema, list);
887
        getAllNamespacesInfo(xsdSchema, list);
884
        result = list;
888
        result = list;
885
      }
889
      }
886
      else if (propertyName.equals(PROPERTY_ELEMENT_FORM_DEFAULT))
890
      else if (propertyName.equals(PROPERTY_ELEMENT_FORM_DEFAULT))
Lines 946-951 Link Here
946
      }
950
      }
947
    }
951
    }
948
952
953
	/**
954
	 * Retrieve a list of all the namespaces that have been defined with the use of xmlns
955
	 * in the schema.  This may or may not be more accurate than searching on the XSDImports
956
	 * Note schemaLocation is not populated by this method, so a user has to fill it in manually
957
	 * 
958
	 * @param theXSDSchema
959
	 * 		the current Schema
960
	 * @param list
961
	 * 		a list of namespaces
962
	 */
963
	public void getAllNamespacesInfo(XSDSchema theXSDSchema, List list) {
964
		Document document = theXSDSchema.getDocument();
965
		Node rootNode = document.getFirstChild();
966
		
967
		NamedNodeMap attributeList = rootNode.getAttributes();
968
		
969
		for (int index = 0; index < attributeList.getLength(); index++) {
970
			Attr attribute = (Attr) attributeList.item(index);			
971
			if (attribute.getNamespaceURI() != null) {
972
				if (checkNamespace(list, attribute.getNodeValue()) == false) {
973
					NamespaceInfo info = new NamespaceInfo();
974
					info.uri = attribute.getNodeValue();
975
					info.prefix = attribute.getLocalName();
976
					info.isPrefixRequired = true;
977
					list.add(info);
978
				}
979
			}
980
		}
981
	}
982
983
	/**
984
	 * Checks to see if a namespace has already been added to the list.
985
	 * @param list
986
	 * 		A list of namespaces
987
	 * @param namespace
988
	 * 		Namespace to check
989
	 * @return
990
	 * 	    true or false.
991
	 */
992
	private boolean checkNamespace(List list, String namespace) {
993
		boolean returnSW = false;
994
		for (Iterator iterator = list.iterator(); iterator.hasNext();) {
995
			NamespaceInfo info = (NamespaceInfo) iterator.next();
996
			if (info.uri.contentEquals(new StringBuffer(namespace))) {
997
				returnSW = true;
998
			}
999
		}
1000
1001
		return returnSW;
1002
	}
1003
    
949
    /**
1004
    /**
950
     * Returns set of named (top-level) element declarations for this schema
1005
     * Returns set of named (top-level) element declarations for this schema
951
     * node.
1006
     * node.

Return to bug 176416