nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 1 | /******************************************************************************* |
| 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_williams | 5677702 | 2005-04-11 06:21:55 +0000 | [diff] [blame] | 11 | package org.eclipse.wst.html.core.internal.validate; |
nitind | 958d79a | 2004-11-23 19:23:00 +0000 | [diff] [blame] | 12 | |
| 13 | import org.w3c.dom.Element; |
| 14 | import org.w3c.dom.Node; |
| 15 | |
| 16 | final 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 | } |