blob: 6bf6fede41ca3baea5fc6ffc29b0e24b285a624f [file] [log] [blame]
nitind958d79a2004-11-23 19:23:00 +00001/*******************************************************************************
2 * Copyright (c) 2004 IBM Corporation and others.
3 * All rights reserved. This program and the accompanying materials
4 * are made available under the terms of the Eclipse Public License v1.0
5 * which accompanies this distribution, and is available at
6 * http://www.eclipse.org/legal/epl-v10.html
7 *
8 * Contributors:
9 * IBM Corporation - initial API and implementation
10 *******************************************************************************/
david_williams56777022005-04-11 06:21:55 +000011package org.eclipse.wst.html.core.internal.validate;
nitind958d79a2004-11-23 19:23:00 +000012
13import org.w3c.dom.Element;
14import org.w3c.dom.Node;
15
16final class SMUtil {
17
18 private SMUtil() {
19 super();
20 }
21
22 /* get an ancestor element ignoring implicit ones. */
23 public static Element getParentElement(Node child) {
24 if (child == null)
25 return null;
26
27 Node p = child.getParentNode();
28 while (p != null) {
29 if (p.getNodeType() == Node.ELEMENT_NODE) {
30 return (Element) p;
31 }
32 p = p.getParentNode();
33 }
34 return null;
35 }
36}