abdera-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jmsn...@apache.org
Subject svn commit: r422030 - in /incubator/abdera/java/trunk: core/src/main/java/org/apache/abdera/parser/ParserOptions.java core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
Date Fri, 14 Jul 2006 20:31:59 GMT
Author: jmsnell
Date: Fri Jul 14 13:31:58 2006
New Revision: 422030

URL: http://svn.apache.org/viewvc?rev=422030&view=rev
Log:
New parser options to tell the parser to ignore formatting whitespace, PIs, comments and Doctype
declarations.

Modified:
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
    incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
    incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java?rev=422030&r1=422029&r2=422030&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/parser/ParserOptions.java
Fri Jul 14 13:31:58 2006
@@ -78,4 +78,13 @@
   boolean getAutodetectCharset();
   
   void setAutodetectCharset(boolean detect);
+  
+  void setIgnoreDoctype(boolean ignore);
+  void setIgnoreComments(boolean ignore);
+  void setIgnoreWhitespace(boolean ignore);
+  void setIgnoreProcessingInstructions(boolean ignore);
+  boolean getIgnoreDoctype();
+  boolean getIgnoreComments();
+  boolean getIgnoreWhitespace();
+  boolean getIgnoreProcessingInstructions();
 }

Modified: incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java?rev=422030&r1=422029&r2=422030&view=diff
==============================================================================
--- incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
(original)
+++ incubator/abdera/java/trunk/core/src/main/java/org/apache/abdera/util/AbstractParserOptions.java
Fri Jul 14 13:31:58 2006
@@ -30,6 +30,10 @@
   protected ParseFilter parseFilter = null;
   protected TextFilter textFilter = null;
   protected boolean detect = true;
+  protected boolean ignoredtd = false;
+  protected boolean ignorecomments = false;
+  protected boolean ignorepi = false;
+  protected boolean ignorespace = false;
 
   protected abstract void initFactory();
   protected abstract void checkFactory(Factory factory);
@@ -73,5 +77,30 @@
   
   public void setAutodetectCharset(boolean detect) {
     this.detect = detect;
+  }
+  
+  public void setIgnoreDoctype(boolean ignore) {
+    this.ignoredtd = ignore;
+  }
+  public void setIgnoreComments(boolean ignore) {
+    this.ignorecomments = ignore;
+  }
+  public void setIgnoreWhitespace(boolean ignore) {
+    this.ignorespace = ignore;
+  }
+  public void setIgnoreProcessingInstructions(boolean ignore) {
+    this.ignorepi = ignore;
+  }
+  public boolean getIgnoreDoctype() {
+    return this.ignoredtd;
+  }
+  public boolean getIgnoreComments() {
+    return this.ignorecomments;
+  }
+  public boolean getIgnoreWhitespace() {
+    return this.ignorespace;
+  }
+  public boolean getIgnoreProcessingInstructions() {
+    return this.ignorepi;
   }
 }

Modified: incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
URL: http://svn.apache.org/viewvc/incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java?rev=422030&r1=422029&r2=422030&view=diff
==============================================================================
--- incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
(original)
+++ incubator/abdera/java/trunk/parser/src/main/java/org/apache/abdera/parser/stax/FOMBuilder.java
Fri Jul 14 13:31:58 2006
@@ -212,6 +212,7 @@
   
   private OMNode applyTextFilter(int type) {
     if (parserOptions != null) { 
+      if (parser.isWhiteSpace() && parserOptions.getIgnoreWhitespace()) return createOMText("",type);
       TextFilter filter = parserOptions.getTextFilter();
       if (filter != null) {
         String value = parser.getText();
@@ -291,16 +292,20 @@
                 ((OMContainerEx) this.document).setComplete(true);
                 break;
             case XMLStreamConstants.SPACE:
-                lastNode = createOMText(XMLStreamConstants.SPACE);
+                if (!parserOptions.getIgnoreWhitespace())
+                  lastNode = createOMText(XMLStreamConstants.SPACE);
                 break;
             case XMLStreamConstants.COMMENT:
-                createComment();
+                if (!parserOptions.getIgnoreComments())
+                  createComment();
                 break;
             case XMLStreamConstants.DTD:
-                createDTD();
+                if (!parserOptions.getIgnoreDoctype())
+                  createDTD();
                 break;
             case XMLStreamConstants.PROCESSING_INSTRUCTION:
-                createPI();
+                if (!parserOptions.getIgnoreProcessingInstructions())
+                  createPI();
                 break;
             case XMLStreamConstants.ENTITY_REFERENCE:
                 lastNode = createOMText(XMLStreamConstants.ENTITY_REFERENCE);



Mime
View raw message