abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r600687 - /incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/PrettyWriter.java
Date Mon, 03 Dec 2007 20:58:51 GMT
Author: jmsnell
Date: Mon Dec  3 12:58:50 2007
New Revision: 600687

URL: http://svn.apache.org/viewvc?rev=600687&view=rev
Log:
Fix class cast exception when working with extension elements

Modified:
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/PrettyWriter.java

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/PrettyWriter.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/PrettyWriter.java?rev=600687&r1=600686&r2=600687&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/PrettyWriter.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/util/PrettyWriter.java
Mon Dec  3 12:58:50 2007
@@ -30,6 +30,8 @@
 
 import org.apache.abdera.model.Base;
 import org.apache.abdera.model.Document;
+import org.apache.abdera.model.Element;
+import org.apache.abdera.model.ElementWrapper;
 import org.apache.abdera.util.AbstractNamedWriter;
 import org.apache.abdera.util.AbstractWriterOptions;
 import org.apache.abdera.writer.NamedWriter;
@@ -86,7 +88,7 @@
       XMLStreamWriter w = StAXUtils.createXMLStreamWriter(out);
       XMLStreamWriter pw = new PrettyStreamWriter(w);
       OMElement om = (base instanceof Document) ? 
-        (OMElement)((Document)base).getRoot() : 
+        getOMElement(((Document)base).getRoot()) : 
         (OMElement)base;
       String charset = options.getCharset();
       if (om.getParent() != null && om.getParent() instanceof OMDocument) {
@@ -103,6 +105,12 @@
     }
   }
 
+  private OMElement getOMElement(Element el) {
+    if (el instanceof ElementWrapper) {
+      return getOMElement(((ElementWrapper)el).getInternal());
+    } else return (OMElement)el;
+  }
+  
   private static class PrettyStreamWriter implements XMLStreamWriter {
     
     private static final int INDENT = 2;



Mime
View raw message