You are viewing a plain text version of this content. The canonical link for it is here.
Posted to woden-dev@ws.apache.org by jk...@apache.org on 2005/06/30 17:41:27 UTC
svn commit: r208637 -
/incubator/woden/java/src/org/apache/woden/internal/util/dom/DOMUtils.java
Author: jkaputin
Date: Thu Jun 30 08:41:26 2005
New Revision: 208637
URL: http://svn.apache.org/viewcvs?rev=208637&view=rev
Log:
Corrected XMLNS uri and added child element methods
Modified:
incubator/woden/java/src/org/apache/woden/internal/util/dom/DOMUtils.java
Modified: incubator/woden/java/src/org/apache/woden/internal/util/dom/DOMUtils.java
URL: http://svn.apache.org/viewcvs/incubator/woden/java/src/org/apache/woden/internal/util/dom/DOMUtils.java?rev=208637&r1=208636&r2=208637&view=diff
==============================================================================
--- incubator/woden/java/src/org/apache/woden/internal/util/dom/DOMUtils.java (original)
+++ incubator/woden/java/src/org/apache/woden/internal/util/dom/DOMUtils.java Thu Jun 30 08:41:26 2005
@@ -6,36 +6,69 @@
import org.w3c.dom.Attr;
import org.w3c.dom.Element;
+import org.w3c.dom.Node;
public class DOMUtils {
- /**
- * The namespaceURI represented by the prefix <code>xmlns</code>.
- */
- private static String NS_URI_XMLNS = "http://www.w3.org/2001/XMLSchema";
+ /**
+ * The namespaceURI represented by the prefix <code>xmlns</code>.
+ */
+ private static String NS_URI_XMLNS = "http://www.w3.org/2000/xmlns/";
- private static final String ATTR_XMLNS = "xmlns";
+ private static final String ATTR_XMLNS = "xmlns";
- /**
- * Returns the value of an attribute of an element. Returns null
- * if the attribute is not found (whereas Element.getAttribute
- * returns "" if an attrib is not found). This method should be
- * used for elements that support extension attributes because it
- * does not track unexpected attributes.
- *
- * @param el Element whose attrib is looked for
- * @param attrName name of attribute to look for
- * @return the attribute value
- */
- static public String getAttribute (Element el, String attrName) {
- String sRet = null;
- Attr attr = el.getAttributeNode(attrName);
+ /**
+ * Returns the value of an attribute of an element. Returns null
+ * if the attribute is not found (whereas Element.getAttribute
+ * returns "" if an attrib is not found). This method should be
+ * used for elements that support extension attributes because it
+ * does not track unexpected attributes.
+ *
+ * @param el Element whose attrib is looked for
+ * @param attrName name of attribute to look for
+ * @return the attribute value
+ */
+ static public String getAttribute (Element el, String attrName) {
+ String sRet = null;
+ Attr attr = el.getAttributeNode(attrName);
- if (attr != null) {
- sRet = attr.getValue();
+ if (attr != null) {
+ sRet = attr.getValue();
+ }
+ return sRet;
+ }
+
+ /**
+ * Return the first child element of the given element. Null if no
+ * children are found.
+ *
+ * @param elem Element whose child is to be returned
+ * @return the first child element.
+ */
+ public static Element getFirstChildElement (Element elem) {
+ for (Node n = elem.getFirstChild (); n != null; n = n.getNextSibling ()) {
+ if (n.getNodeType () == Node.ELEMENT_NODE) {
+ return (Element) n;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Return the next sibling element of the given element. Null if no
+ * more sibling elements are found.
+ *
+ * @param elem Element whose sibling element is to be returned
+ * @return the next sibling element.
+ */
+ public static Element getNextSiblingElement (Element elem) {
+ for (Node n = elem.getNextSibling (); n != null; n = n.getNextSibling ()) {
+ if (n.getNodeType () == Node.ELEMENT_NODE) {
+ return (Element) n;
+ }
+ }
+ return null;
}
- return sRet;
- }
}
---------------------------------------------------------------------
To unsubscribe, e-mail: woden-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: woden-dev-help@ws.apache.org