abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r417652 - in /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax: FOMContent.java FOMDiv.java
Date Wed, 28 Jun 2006 03:08:03 GMT
Author: jmsnell
Date: Tue Jun 27 20:08:03 2006
New Revision: 417652

URL: http://svn.apache.org/viewvc?rev=417652&view=rev
Log:

 Content.getValue() with type="xhtml" ... now returns the serialized string without the wrapper
div
 Content.setValue() with type="xhtml" ... now automatically adds the wrapper div (regardless
of whether or not the value param already has a div
 
 This automatically bubbles down to entry.getContent(...) and entry.setContent(...)
 

Modified:
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java?rev=417652&r1=417651&r2=417652&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMContent.java
Tue Jun 27 20:08:03 2006
@@ -212,7 +212,8 @@
     } else if (Type.HTML.equals(type)) {
       val = getText();
     } else if (Type.XHTML.equals(type)) {
-      val = this.getFirstChildWithName(Constants.DIV).toString();
+      //val = this.getFirstChildWithName(Constants.DIV).toString();
+      val = ((FOMDiv)this.getFirstChildWithName(Constants.DIV)).getInternalValue();
     } else if (Type.XML.equals(type)) {
       val = this.getFirstElement().toString();
     } else if (Type.MEDIA.equals(type)) {
@@ -235,6 +236,7 @@
         try {
           baseUri = getResolvedBaseUri();
         } catch (Exception e) {}
+        value = "<div xmlns=\"" + XHTML_NS + "\">" + value + "</div>";
         Element element = _parse(value, baseUri);
         if (element != null && element instanceof Div)
           setValueElement((Div)element);

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java?rev=417652&r1=417651&r2=417652&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMDiv.java
Tue Jun 27 20:08:03 2006
@@ -17,7 +17,12 @@
 */
 package org.apache.abdera.parser.stax;
 
+import java.io.ByteArrayOutputStream;
+import java.util.Iterator;
+
 import javax.xml.namespace.QName;
+import javax.xml.stream.XMLOutputFactory;
+import javax.xml.stream.XMLStreamWriter;
 
 import org.apache.abdera.factory.Factory;
 import org.apache.abdera.model.Div;
@@ -26,6 +31,7 @@
 import org.apache.axiom.om.OMException;
 import org.apache.axiom.om.OMFactory;
 import org.apache.axiom.om.OMNamespace;
+import org.apache.axiom.om.OMNode;
 import org.apache.axiom.om.OMXMLParserWrapper;
 
 
@@ -118,4 +124,20 @@
       _removeAllChildren();
   }
 
+  protected String getInternalValue() {
+    try {
+      ByteArrayOutputStream out = new ByteArrayOutputStream();
+      XMLStreamWriter writer = 
+        XMLOutputFactory.newInstance().createXMLStreamWriter(out);
+      writer.writeStartElement("");
+      for (Iterator nodes = this.getChildren(); nodes.hasNext();) {
+        OMNode node = (OMNode) nodes.next();
+        node.serialize(writer);
+      }
+      writer.writeEndElement();
+      return out.toString().substring(2);
+    } catch (Exception e) {}
+    return "";
+  }
+  
 }



Mime
View raw message