incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From svanteschub...@apache.org
Subject svn commit: r1643200 - in /incubator/odf/trunk/validator/src: main/java/org/odftoolkit/odfvalidator/ test/java/org/odftoolkit/odfvalidator/ test/resources/
Date Fri, 05 Dec 2014 09:18:42 GMT
Author: svanteschubert
Date: Fri Dec  5 09:18:42 2014
New Revision: 1643200

URL: http://svn.apache.org/viewvc?rev=1643200&view=rev
Log:
validator: fix bugs in checking character content in foreign elements

See ODF 1.2 section 3.17 Foreign Elements and Attributes.

In particular, for ODF 1.2 it was not actually checked whether an
ancestor is a <text:p>/<text:h> element (which is where it differs from
ODF 1.1).

Added:
    incubator/odf/trunk/validator/src/test/resources/extnumberstyle-processcontent.ods
    incubator/odf/trunk/validator/src/test/resources/extnumberstyle.ods
Modified:
    incubator/odf/trunk/validator/src/main/java/org/odftoolkit/odfvalidator/ForeignContentFilter.java
    incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/ValidTest.java

Modified: incubator/odf/trunk/validator/src/main/java/org/odftoolkit/odfvalidator/ForeignContentFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/main/java/org/odftoolkit/odfvalidator/ForeignContentFilter.java?rev=1643200&r1=1643199&r2=1643200&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/main/java/org/odftoolkit/odfvalidator/ForeignContentFilter.java
(original)
+++ incubator/odf/trunk/validator/src/main/java/org/odftoolkit/odfvalidator/ForeignContentFilter.java
Fri Dec  5 09:18:42 2014
@@ -106,7 +106,10 @@ class ForeignContentFilter extends XMLFi
         else
         {
             if( isProcessContent() )
+            {
+                m_aParagraphAncestorElements.removeElementAt(m_aParagraphAncestorElements.size()-1);
                 super.endElement(aUri,aLocalName,aQName);
+            }
         }
     }
 
@@ -123,7 +126,9 @@ class ForeignContentFilter extends XMLFi
                 String aProcessContentValue = aAtts.getValue( OFFICE_NAMESPACE_URI, PROCESS_CONTENT
);
                 if( m_aVersion.compareTo( OdfVersion.V1_2 ) >= 0 )
                 {
-                    bProcessContent = aProcessContentValue != null ? aProcessContentValue.equals(TRUE)
: true;
+                    bProcessContent = aProcessContentValue != null
+                                        ? aProcessContentValue.equals(TRUE)
+                                        : hasParagraphAncestorElement();
                 }
                 else
                 {

Modified: incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/ValidTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/ValidTest.java?rev=1643200&r1=1643199&r2=1643200&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/ValidTest.java
(original)
+++ incubator/odf/trunk/validator/src/test/java/org/odftoolkit/odfvalidator/ValidTest.java
Fri Dec  5 09:18:42 2014
@@ -84,5 +84,62 @@ public class ValidTest extends OdfValida
 		}
         //Assert.assertTrue(output.contains("dummy.odt:Info:no errors, no warnings"));
     }	
-	
+
+    @Test
+    public void validateForeignElementCharacterContentStrict() {
+        String output = "";
+        try {
+            String name = "extnumberstyle.ods";
+            output = doValidation(name, OdfVersion.V1_2, OdfValidatorMode.CONFORMANCE, true);
+        } catch (Throwable t) {
+            t.printStackTrace();
+            Assert.fail(t.toString());
+        }
+        if(output.contains("Exception")){
+            System.out.println("OUTPUT:" + output);
+            Assert.fail("An exception occurred during validation!");
+        }
+        System.out.println("OUTPUT:" + output);
+        Assert.assertTrue(output.contains("Error:"));
+        Assert.assertTrue(output.contains("styles.xml[32,19]:"));
+    }
+
+    @Test
+    public void validateForeignElementCharacterContentExtended() {
+        String output = "";
+        try {
+            String name = "extnumberstyle.ods";
+            output = doValidation(name, OdfVersion.V1_2, OdfValidatorMode.EXTENDED_CONFORMANCE,
true);
+        } catch (Throwable t) {
+            t.printStackTrace();
+            Assert.fail(t.toString());
+        }
+        if(output.contains("Exception")){
+            System.out.println("OUTPUT:" + output);
+            Assert.fail("An exception occurred during validation!");
+        }
+        System.out.println("OUTPUT:" + output);
+        Assert.assertFalse(output.contains("unexpected character literal"));
+        Assert.assertFalse(output.contains("Error:"));
+    }
+
+    @Test
+    public void validateForeignElementCharacterContentExtendedProcessContent() {
+        String output = "";
+        try {
+            String name = "extnumberstyle-processcontent.ods";
+            output = doValidation(name, OdfVersion.V1_2, OdfValidatorMode.EXTENDED_CONFORMANCE,
true);
+        } catch (Throwable t) {
+            t.printStackTrace();
+            Assert.fail(t.toString());
+        }
+        if(output.contains("Exception")){
+            System.out.println("OUTPUT:" + output);
+            Assert.fail("An exception occurred during validation!");
+        }
+        System.out.println("OUTPUT:" + output);
+        Assert.assertTrue(output.contains("unexpected character literal"));
+        Assert.assertTrue(output.contains("styles.xml[34,79]:"));
+    }
+
 }

Added: incubator/odf/trunk/validator/src/test/resources/extnumberstyle-processcontent.ods
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/test/resources/extnumberstyle-processcontent.ods?rev=1643200&view=auto
==============================================================================
Binary files incubator/odf/trunk/validator/src/test/resources/extnumberstyle-processcontent.ods
(added) and incubator/odf/trunk/validator/src/test/resources/extnumberstyle-processcontent.ods
Fri Dec  5 09:18:42 2014 differ

Added: incubator/odf/trunk/validator/src/test/resources/extnumberstyle.ods
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/test/resources/extnumberstyle.ods?rev=1643200&view=auto
==============================================================================
Binary files incubator/odf/trunk/validator/src/test/resources/extnumberstyle.ods (added) and
incubator/odf/trunk/validator/src/test/resources/extnumberstyle.ods Fri Dec  5 09:18:42 2014
differ



Mime
View raw message