View | Details | Raw Unified | Return to bug 263976
Collapse All | Expand All

(-)src/org/eclipse/core/internal/content/XMLRootHandler.java (+8 lines)
Lines 72-77 Link Here
72
	 * successful to the point of finding the top-level element.
72
	 * successful to the point of finding the top-level element.
73
	 */
73
	 */
74
	private String namespaceFound = null;
74
	private String namespaceFound = null;
75
	
76
	private String versionFound = null;
75
		
77
		
76
	public XMLRootHandler(boolean checkRoot) {
78
	public XMLRootHandler(boolean checkRoot) {
77
		this.checkRoot = checkRoot;
79
		this.checkRoot = checkRoot;
Lines 162-167 Link Here
162
		return namespaceFound;
164
		return namespaceFound;
163
	}
165
	}
164
166
167
	public String getVersion() {
168
		return this.versionFound;
169
	}
170
	
171
165
	public boolean parseContents(InputSource contents) throws IOException, ParserConfigurationException, SAXException {
172
	public boolean parseContents(InputSource contents) throws IOException, ParserConfigurationException, SAXException {
166
		// Parse the file into we have what we need (or an error occurs).
173
		// Parse the file into we have what we need (or an error occurs).
167
		try {
174
		try {
Lines 219-224 Link Here
219
	public final void startElement(final String uri, final String elementName, final String qualifiedName, final Attributes attributes) throws SAXException {
226
	public final void startElement(final String uri, final String elementName, final String qualifiedName, final Attributes attributes) throws SAXException {
220
		elementFound = elementName;
227
		elementFound = elementName;
221
		namespaceFound = uri;
228
		namespaceFound = uri;
229
		versionFound = attributes.getValue("version");
222
		throw new StopParsingException();
230
		throw new StopParsingException();
223
	}
231
	}
224
232
(-)src/org/eclipse/core/runtime/content/XMLRootElementContentDescriber2.java (-5 / +18 lines)
Lines 32-38 Link Here
32
 * </p>
32
 * </p>
33
 * <p>
33
 * <p>
34
 * The value of "element" is specified using such a format
34
 * The value of "element" is specified using such a format
35
 * <code>{namespace}name/dtd</code>. The namespace or dtd part  
35
 * <code>{namespace}name/dtd:version</code>. The namespace or dtd part  
36
 * can be omitted and accepted are values like <code>name/dtd</code>,
36
 * can be omitted and accepted are values like <code>name/dtd</code>,
37
 * <code>{ns}name</code> and <code>name</code>.
37
 * <code>{ns}name</code> and <code>name</code>.
38
 * </p>
38
 * </p>
Lines 81-91 Link Here
81
		private String namespace;
81
		private String namespace;
82
		private String element;
82
		private String element;
83
		private String dtd;
83
		private String dtd;
84
		private String version;
84
		
85
		
85
		public QualifiedElement(String namespace, String element, String dtd) {
86
		public QualifiedElement(String namespace, String element, String dtd, String version) {
86
			this.namespace = namespace;
87
			this.namespace = namespace;
87
			this.element = element;
88
			this.element = element;
88
			this.dtd = dtd;
89
			this.dtd = dtd;
90
			this.version = version;
89
		}
91
		}
90
92
91
		public QualifiedElement(String qualifiedElement) {
93
		public QualifiedElement(String qualifiedElement) {
Lines 102-107 Link Here
102
				dtd = qualifiedElement.substring(dtdSlash+1);
104
				dtd = qualifiedElement.substring(dtdSlash+1);
103
				qualifiedElement = qualifiedElement.substring(0, dtdSlash);
105
				qualifiedElement = qualifiedElement.substring(0, dtdSlash);
104
			}
106
			}
107
			// Extract version part
108
			int versionSlash = qualifiedElement.indexOf(':');
109
			if (versionSlash > 0) {
110
				version = qualifiedElement.substring(versionSlash + 1);
111
				qualifiedElement = qualifiedElement.substring(0, versionSlash);
112
			}
105
			// Check if the name is a wildcard
113
			// Check if the name is a wildcard
106
			element = ("*".equals(qualifiedElement) ? null : qualifiedElement);
114
			element = ("*".equals(qualifiedElement) ? null : qualifiedElement);
107
		}
115
		}
Lines 117-127 Link Here
117
			return dtd;
125
			return dtd;
118
		}
126
		}
119
		
127
		
120
		public boolean matches(String someNamespace, String someElement, String someDtd) {
128
		public String getVersion() {
129
			return version;
130
		}
131
		
132
		public boolean matches(String someNamespace, String someElement, String someDtd, String someVersion) {
121
			boolean nsMatch = this.namespace != null ? this.namespace.equals(someNamespace) : true;
133
			boolean nsMatch = this.namespace != null ? this.namespace.equals(someNamespace) : true;
122
			boolean elementEquals = this.element != null ? this.element.equals(someElement) : true;
134
			boolean elementEquals = this.element != null ? this.element.equals(someElement) : true;
123
			boolean dtdEquals = this.dtd != null ? this.dtd.equals(someDtd) : true;
135
			boolean dtdEquals = this.dtd != null ? this.dtd.equals(someDtd) : true;
124
			return nsMatch && elementEquals && dtdEquals;
136
			boolean versionEquals = this.version != null ? this.version.equals(someVersion) : true;
137
			return nsMatch && elementEquals && dtdEquals && versionEquals;
125
		}
138
		}
126
	}
139
	}
127
	
140
	
Lines 154-160 Link Here
154
		if (elementsToFind != null) {
167
		if (elementsToFind != null) {
155
			boolean foundOne = false;
168
			boolean foundOne = false;
156
			for (int i = 0; i < elementsToFind.length && !foundOne; ++i) {
169
			for (int i = 0; i < elementsToFind.length && !foundOne; ++i) {
157
				foundOne |= elementsToFind[i].matches(xmlHandler.getRootNamespace(), xmlHandler.getRootName(), xmlHandler.getDTD());
170
				foundOne |= elementsToFind[i].matches(xmlHandler.getRootNamespace(), xmlHandler.getRootName(), xmlHandler.getDTD(), xmlHandler.getVersion());
158
			}
171
			}
159
			if (!foundOne)
172
			if (!foundOne)
160
				return INDETERMINATE;
173
				return INDETERMINATE;

Return to bug 263976