abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r420958 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/model/Element.java parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Date Tue, 11 Jul 2006 19:38:14 GMT
Author: jmsnell
Date: Tue Jul 11 12:38:13 2006
New Revision: 420958

URL: http://svn.apache.org/viewvc?rev=420958&view=rev
Log:
We need a way of listing the attributes on an element, especially extension attributes

  * add Element.getAttributes() which returns a List<QName>
  * add Element.getExtensionAttributes() which returns a List<QName> minus attributes
that are in the containing elements namespace

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java?rev=420958&r1=420957&r2=420958&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java (original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/model/Element.java Tue
Jul 11 12:38:13 2006
@@ -20,6 +20,7 @@
 import java.io.Serializable;
 import java.net.URI;
 import java.net.URISyntaxException;
+import java.util.List;
 
 import javax.xml.namespace.QName;
 
@@ -98,6 +99,18 @@
 
   String getAttributeValue(QName qname);
 
+  /**
+   * Returns a listing of all attributes on this element
+   */
+  List<QName> getAttributes();
+  
+  /**
+   * Returns a listing of extension attributes on this element
+   * (extension attributes are attributes whose namespace URI
+   * is different than the elements)
+   */
+  List<QName> getExtensionAttributes();
+  
   /**
    * Returns the value of the named attribute
    */

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java?rev=420958&r1=420957&r2=420958&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMElement.java
Tue Jul 11 12:38:13 2006
@@ -461,6 +461,28 @@
     return (text != null) ? text.getValue() : null;
   }
   
+  public List<QName> getAttributes() {
+    List<QName> list = new ArrayList<QName>();
+    for (Iterator i = getAllAttributes(); i.hasNext();) {
+      OMAttribute attr = (OMAttribute) i.next();
+      list.add(attr.getQName());
+    }
+    return list;
+  }
+  
+  public List<QName> getExtensionAttributes() {
+    List<QName> list = new ArrayList<QName>();
+    for (Iterator i = getAllAttributes(); i.hasNext();) {
+      OMAttribute attr = (OMAttribute) i.next();
+      String namespace = attr.getNamespace().getName();
+      if (!namespace.equals(getNamespace().getName()) &&
+          !namespace.equals(""))
+        list.add(attr.getQName());
+    }
+    return list;
+  }
+  
+  
   protected Element _parse(String value, URI baseUri) {
     if (value == null) return null;
     FOMFactory fomfactory = (FOMFactory) factory;



Mime
View raw message