You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lenya.apache.org by mi...@apache.org on 2004/03/05 12:01:21 UTC

cvs commit: cocoon-lenya/src/java/org/apache/lenya/xml DOMUtil.java

michi       2004/03/05 03:01:21

  Modified:    src/java/org/apache/lenya/xml DOMUtil.java
  Log:
  elementExists method added
  
  Revision  Changes    Path
  1.14      +22 -3     cocoon-lenya/src/java/org/apache/lenya/xml/DOMUtil.java
  
  Index: DOMUtil.java
  ===================================================================
  RCS file: /home/cvs/cocoon-lenya/src/java/org/apache/lenya/xml/DOMUtil.java,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -r1.13 -r1.14
  --- DOMUtil.java	1 Mar 2004 16:18:23 -0000	1.13
  +++ DOMUtil.java	5 Mar 2004 11:01:21 -0000	1.14
  @@ -156,8 +156,27 @@
       }
   
       /**
  -       *
  -       */
  +     * Check if elements exists
  +     */
  +    public boolean elementExists(Element element, XPath xpath)
  +        throws Exception {
  +        log.debug(xpath);
  +
  +        if (xpath.parts.length > 0) {
  +            NodeList nl = element.getElementsByTagName(xpath.parts[0]);
  +
  +            if (nl.getLength() == 0) {
  +                return false;
  +            } else if (nl.getLength() == 1) {
  +                return true;
  +            }
  +        }
  +    return false;
  +    }
  +
  +    /**
  +     * Get element via XPath
  +     */
       public Element getElement(Element element, XPath xpath)
           throws Exception {
           log.debug(xpath);
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: lenya-cvs-unsubscribe@cocoon.apache.org
For additional commands, e-mail: lenya-cvs-help@cocoon.apache.org