incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1172439 [2/2] - in /incubator/odf/trunk/validator: ./ nbproject/ src/org/odftoolkit/odfvalidator/
Date Mon, 19 Sep 2011 05:33:54 GMT
Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentFilter.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentFilter.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,191 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ * 
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * 
+ * Use is subject to license terms.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+import java.util.HashSet;
+import java.util.Vector;
+import org.odftoolkit.odfdom.dom.OdfNamespaceNames;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+class ForeignContentFilter extends XMLFilterImpl {
+
+    private static final String OFFICE_NAMESPACE_URI = OdfNamespaceNames.OFFICE.getNamespaceUri();
+    private static final String TEXT_NAMESPACE_URI = OdfNamespaceNames.TEXT.getNamespaceUri();
+
+    private static final String H = "h";
+    private static final String P = "p";
+
+    private static final String PROCESS_CONTENT = "process-content";
+    private static final String TRUE = "true";
+
+    // Set of ODF namespace URIs
+    private static HashSet<String> m_aODFNamespaceSet = null;
+
+    // This list contains a boolean for all ancestor foreign elements.
+    // That boolean values specifies whether the element content is processed or not.
+    private Vector<Boolean> m_aAlienElementProcessContents = null;
+
+    // This list contains a boolean for all ancestor elements.
+    // That boolean values specifies whether the element is a text:h ot text:p
+    // element itself or has a text:h or text:p ancestor element.
+    private Vector<Boolean> m_aParagraphAncestorElements = null;
+
+    private ForeignContentListener m_aForeignContentListener = null;
+
+    private OdfVersion m_aVersion = null;
+    private Logger m_aLogger;
+
+    /** Creates a new instance of NamespaceFilter */
+    ForeignContentFilter( Logger aLogger, OdfVersion aVersion, ForeignContentListener aForeignContentListener ) {
+        m_aLogger = aLogger;
+        m_aVersion = aVersion;
+        m_aForeignContentListener = aForeignContentListener;
+
+        m_aAlienElementProcessContents = new Vector<Boolean>();
+        m_aParagraphAncestorElements = new Vector<Boolean>();
+        
+        m_aODFNamespaceSet = new HashSet<String>();
+        m_aODFNamespaceSet.add( OdfNamespaceNames.OFFICE.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.STYLE.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.TEXT.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.TABLE.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.DRAW.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.FO.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.DC.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.META.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.NUMBER.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.SVG.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.CHART.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.DR3D.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.FORM.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.PRESENTATION.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.SMIL.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.CONFIG.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.SCRIPT.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.XLINK.getNamespaceUri() );
+        m_aODFNamespaceSet.add( OdfNamespaceNames.XFORMS.getNamespaceUri() );
+        if( m_aVersion.compareTo( OdfVersion.V1_2 ) >= 0 )
+        {
+            m_aODFNamespaceSet.add( OdfNamespaceNames.XHTML.getNamespaceUri() );
+            m_aODFNamespaceSet.add( OdfNamespaceNames.GRDDL.getNamespaceUri() );
+            m_aODFNamespaceSet.add( OdfNamespaceNames.DB.getNamespaceUri() );
+            m_aODFNamespaceSet.add( javax.xml.XMLConstants.XML_NS_URI );
+        }
+    }
+
+
+    @Override
+    public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
+        if( isAlienNamespace(aUri) )
+        {
+            m_aAlienElementProcessContents.removeElementAt( m_aAlienElementProcessContents.size()-1 );
+        }
+        else
+        {
+            if( isProcessContent() )
+                super.endElement(aUri,aLocalName,aQName);
+        }
+    }
+
+
+    @Override
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAtts) throws SAXException
+    {
+        boolean bProcessContent = isProcessContent();
+        
+        if( isAlienNamespace(aUri) )
+        {
+            if( bProcessContent )
+            {
+                String aProcessContentValue = aAtts.getValue( OFFICE_NAMESPACE_URI, PROCESS_CONTENT );
+                if( m_aVersion.compareTo( OdfVersion.V1_2 ) >= 0 )
+                {
+                    bProcessContent = aProcessContentValue != null ? aProcessContentValue.equals(TRUE) : true;
+                }
+                else
+                {
+                    bProcessContent = aProcessContentValue == null || aProcessContentValue.equals(TRUE);
+                }
+
+                if( m_aForeignContentListener!= null )
+                    m_aForeignContentListener.foreignElementDetected(aUri, aLocalName, aQName, aAtts);
+                m_aLogger.logInfo( String.format("extension element <%s> found, element is ignored, element content is %s.",aQName,bProcessContent?"processed":"is ignored"), false);
+            }
+            m_aAlienElementProcessContents.addElement( bProcessContent );
+        }
+        else if( bProcessContent )
+        {
+            Attributes aOldAtts = aAtts;
+
+            AttributesImpl aNewAtts = null;
+            int i = aOldAtts.getLength();
+            while( i>0 ) {
+                --i;
+                String aAttrUri = aOldAtts.getURI(i);
+                if ( isAlienNamespace( aAttrUri ) ) {
+                    if (aNewAtts == null) {
+                        aNewAtts = new AttributesImpl(aOldAtts);
+                        aAtts = aNewAtts;
+                    }
+                    if( m_aForeignContentListener!= null )
+                        m_aForeignContentListener.foreignAttributeDetected(aAttrUri, aOldAtts.getLocalName(i), aOldAtts.getQName(i), aOldAtts.getValue(i));
+                    m_aLogger.logInfo( String.format("extension attribute '%s' of element <%s> found and ignored.",aAtts.getQName(i),aQName), false);
+                    aNewAtts.removeAttribute(i);
+                }
+            }
+
+            boolean bParagraphAncestor = hasParagraphAncestorElement();
+            bParagraphAncestor |= ((aLocalName.equals(P) || aLocalName.equals(H)) && aUri.equals(TEXT_NAMESPACE_URI));
+            m_aParagraphAncestorElements.add(bParagraphAncestor);
+
+            super.startElement(aUri, aLocalName, aQName, aAtts);
+        }
+    }
+    
+    
+
+    private boolean isAlienNamespace( String aUri )
+    {
+        return !m_aODFNamespaceSet.contains(aUri);
+    }
+
+    private boolean isProcessContent()
+    {
+        return m_aAlienElementProcessContents.isEmpty() ? true : m_aAlienElementProcessContents.lastElement();
+    }
+
+    private boolean hasParagraphAncestorElement()
+    {
+        return m_aParagraphAncestorElements.isEmpty() ? false : m_aParagraphAncestorElements.lastElement();
+    }
+
+    @Override
+    public void characters(char[] aChars, int nStart, int nLength) throws SAXException {
+        if( isProcessContent() )
+            super.characters(aChars, nStart, nLength);
+    }
+    
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentListener.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentListener.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentListener.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ForeignContentListener.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,39 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ * 
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * 
+ * Use is subject to license terms.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+import org.xml.sax.Attributes;
+
+/**
+ * Listener interface for foreign elements and attributes that are detected while
+ * validating a stream.
+ *
+ * @author Michael Brauer
+ */
+interface ForeignContentListener {
+    
+    void foreignElementDetected( String aUri, String aLocalName, String aQName, Attributes aAtts );
+
+    void foreignAttributeDetected( String aUri, String aLocalName, String aQName, String aValue );
+    
+}

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java Mon Sep 19 05:33:53 2011
@@ -26,17 +26,20 @@ import java.io.PrintStream;
 
 import org.xml.sax.SAXParseException;
 
-class Logger {
-    
-    static final int INFO = 2;
-    static final int WARNING = 1;
-    static final int ERROR = 0;
+public class Logger {
+
+    public enum LogLevel
+    {
+        ERROR,
+        WARNING,
+        INFO
+    };
     
     private String m_aFileName;
     private String m_aEntryName;
     private PrintStream m_aOut;
     private boolean m_bError;
-    private int m_nLevel;
+    private LogLevel m_nLevel;
     
     private static final String INFO_PREFIX = "Info:";
     private static final String WARNING_PREFIX = "Warning:";
@@ -44,7 +47,7 @@ class Logger {
     private static final String FATAL_PREFIX = "Fatal:";
     
     /** Creates a new instance of SchemaErrorHandler */
-    Logger( String aFileName, String aEntryName, PrintStream aOut , int nLevel) {
+    Logger( String aFileName, String aEntryName, PrintStream aOut , LogLevel nLevel) {
         m_aFileName = aFileName;
         m_aEntryName = aEntryName;
         m_aOut = aOut;
@@ -62,7 +65,7 @@ class Logger {
     }
 
     void logWarning(String aMsg) {
-        if( m_nLevel >= WARNING )
+        if( m_nLevel.compareTo(LogLevel.WARNING) >= 0 )
             logMessage( WARNING_PREFIX, aMsg );
     }
 
@@ -72,18 +75,18 @@ class Logger {
     }
 
     void logError(String aMsg) {
-        if( m_nLevel >= ERROR )
+        if( m_nLevel.compareTo(LogLevel.ERROR) >= 0 )
             logMessage( ERROR_PREFIX, aMsg );
         m_bError = true;
     }
 
     void logInfo(String aMsg, boolean bForceOutput) {
-        if( m_nLevel >= INFO || bForceOutput )
+        if( m_nLevel.compareTo(LogLevel.INFO) >= 0 || bForceOutput )
             logMessage( INFO_PREFIX, aMsg );
     }
     
     void logWarning(SAXParseException e) {
-        if( m_nLevel >= WARNING )
+        if( m_nLevel.compareTo(LogLevel.WARNING) >= 0 )
             logMessage( WARNING_PREFIX, e );
     }
 
@@ -93,7 +96,7 @@ class Logger {
     }
 
     void logError(SAXParseException e) {
-        if( m_nLevel >= ERROR )
+        if( m_nLevel.compareTo(LogLevel.ERROR) >= 0 )
             logMessage( ERROR_PREFIX, e );
         m_bError = true;
     }

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java Mon Sep 19 05:33:53 2011
@@ -38,7 +38,7 @@ import java.util.Vector;
  */
 public class Main {
 
-    private static final String VERSION="1.1.2";
+    private static final String VERSION="1.1.3";
     
     /** Creates a new instance of Main */
     public Main() {
@@ -59,10 +59,10 @@ public class Main {
         boolean bPrintHelp = false;
         boolean bPrintVersion = false;
         boolean bRecursive = false;
-        int nLogLevel = Logger.ERROR;
-        int nMode = ODFPackageValidator.VALIDATE;
+        Logger.LogLevel nLogLevel = Logger.LogLevel.ERROR;
+        OdfValidatorMode eMode = OdfValidatorMode.VALIDATE;
         List<String> aFileNames = new Vector<String>();
-        String aVersion = null;
+        OdfVersion aVersion = null;
 
         boolean bCommandLineValid = true;
         List<String> aArgList = Arrays.asList(aArgs);
@@ -72,7 +72,7 @@ public class Main {
             String aArg = aArgIter.next();
             if( aArg.equals("-c") )
             {
-                nMode = ODFPackageValidator.CHECK_CONFORMANCE;
+                eMode = OdfValidatorMode.CHECK_CONFORMANCE;
             }
             else if( aArg.equals("-d") )
             {
@@ -80,7 +80,7 @@ public class Main {
             }
             else if( aArg.equals("-e") )
             {
-                nMode = ODFPackageValidator.CHECK_EXTENDED_CONFORMANCE;
+                eMode = OdfValidatorMode.CHECK_EXTENDED_CONFORMANCE;
             }
             else if( aArg.equals("-f") )
             {
@@ -110,15 +110,15 @@ public class Main {
             }
             else if( aArg.equals("-s") )
             {
-                nMode = ODFPackageValidator.VALIDATE_STRICT;
+                eMode = OdfValidatorMode.VALIDATE_STRICT;
             }
             else if( aArg.equals("-v") )
             {
-                nLogLevel = Logger.INFO;
+                nLogLevel = Logger.LogLevel.INFO;
             }
             else if( aArg.equals("-w") )
             {
-                nLogLevel = Logger.WARNING;
+                nLogLevel = Logger.LogLevel.WARNING;
             }
             else if( aArg.equals("-x") )
             {
@@ -147,7 +147,7 @@ public class Main {
             }
             else if( aArg.equals("-1.0") || aArg.equals("-1.1") || aArg.equals("-1.2") )
             {
-                aVersion = aArg.substring(1);
+                aVersion = OdfVersion.valueOf( aArg.substring(1), false );
             }
             else if( aArg.startsWith("-") )
             {
@@ -239,11 +239,11 @@ public class Main {
 
             if( aConfigFileName != null )
             {
-                aValidator.validate(aOut, aConfig, nMode );
+                aValidator.validate(aOut, aConfig, eMode );
             }
             else
             {
-                aValidator.validate(aOut, aFileNames, aExcludeRegExp, nMode, bRecursive, aFilterFileName );
+                aValidator.validate(aOut, aFileNames, aExcludeRegExp, eMode, bRecursive, aFilterFileName );
             }
         }
         catch( ODFValidatorException e )

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java Mon Sep 19 05:33:53 2011
@@ -22,14 +22,47 @@
 
 package org.odftoolkit.odfvalidator;
 
-class ManifestEntry
+public class ManifestEntry
 {
-    String m_aFullPath;
-    String m_aMediaType;
+    private String m_aFullPath;
+    private String m_aMediaType;
     
     ManifestEntry(String aFullPath, String aMediaType)
     {
         m_aFullPath = aFullPath;
         m_aMediaType = aMediaType;
     }
+
+    String getFullPath()
+    {
+        return m_aFullPath;
+    }
+
+    String getMediaType()
+    {
+        return m_aMediaType;
+    }
+
+    boolean isOpenDocumentMediaType()
+    {
+        return m_aMediaType!=null && isOpenDocumentMediaType(m_aMediaType);
+    }
+
+    static boolean isOpenDocumentMediaType( String aMediaType )
+    {
+        if( aMediaType.length() >14 && aMediaType.substring(12,14).equals("x-") )
+        {
+            String aNewMediaType = aMediaType.substring(0,12) + aMediaType.substring(14);
+            aMediaType = aNewMediaType;
+        }
+
+        return aMediaType.equals(ODFMediaTypes.TEXT_MEDIA_TYPE) ||
+                aMediaType.equals(ODFMediaTypes.GRAPHICS_MEDIA_TYPE) ||
+                aMediaType.equals(ODFMediaTypes.SPREADSHEET_MEDIA_TYPE) ||
+                aMediaType.equals(ODFMediaTypes.PRESENTATION_MEDIA_TYPE) ||
+                aMediaType.equals(ODFMediaTypes.FORMULA_MEDIA_TYPE) ||
+                aMediaType.equals(ODFMediaTypes.CHART_MEDIA_TYPE);
+    }
+
+
 }
\ No newline at end of file

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntryListener.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntryListener.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntryListener.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntryListener.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,29 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ * 
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * 
+ * Use is subject to license terms.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+interface ManifestEntryListener {
+    
+    void foundManifestEntry( ManifestEntry aManifestEntry );
+    
+}

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java Mon Sep 19 05:33:53 2011
@@ -24,7 +24,6 @@ package org.odftoolkit.odfvalidator;
 
 import java.io.IOException;
 import java.io.StringReader;
-import java.util.Vector;
 import org.xml.sax.Attributes;
 import org.xml.sax.InputSource;
 import org.xml.sax.SAXException;
@@ -42,12 +41,14 @@ class ManifestFilter extends NamespaceFi
     
     private Logger m_aLogger;
     
-    private String m_aMediaType = "";
-    private Vector<ManifestEntry> m_aSubDocs = new Vector<ManifestEntry>();
+    private ManifestListener m_aManifestListener = null;
+    private ManifestEntryListener m_aManifestEntryListener = null;
     
     /** Creates a new instance of KnownIssueFilter */
-    ManifestFilter( Logger aLogger ) {
+    ManifestFilter( Logger aLogger, ManifestListener aManifestListener, ManifestEntryListener aManifestEntryListener ) {
         m_aLogger = aLogger;
+        m_aManifestListener = aManifestListener;
+        m_aManifestEntryListener = aManifestEntryListener;
     }
 
     @Override
@@ -85,44 +86,21 @@ class ManifestFilter extends NamespaceFi
         super.startElement(aUri, aLocalName, aQName, aAtts);
         if( (aUri.equals(MANIFEST_NAMESPACE_URI) || aUri.equals(OOO_MANIFEST_NAMESPACE_URI)) && aLocalName.equals(FILE_ENTRY))
         {
+            String aFullPath = aAtts.getValue(aUri,FULL_PATH);
             String aMediaType = aAtts.getValue(aUri,MEDIA_TYPE);
-            if( aMediaType != null && isOpenDocumentMediaType(aMediaType))
+            if( aFullPath != null )
             {
-                String aFullPath = aAtts.getValue(aUri,FULL_PATH);
-                if( aFullPath != null )
+                if( aFullPath.equals("/") )
                 {
-                    if( aFullPath.equals("/") )
-                        m_aMediaType = aMediaType;
-                    else
-                        m_aSubDocs.add( new ManifestEntry(aFullPath,aMediaType));
+                    if( m_aManifestListener != null )
+                        m_aManifestListener.setMediaType( aMediaType );
+                }
+                else
+                {
+                    if( m_aManifestEntryListener != null )
+                        m_aManifestEntryListener.foundManifestEntry( new ManifestEntry(aFullPath,aMediaType) );
                 }
             }
         }
     }
-    
-    private boolean isOpenDocumentMediaType( String aMediaType )
-    {
-        if( aMediaType.length() >14 && aMediaType.substring(12,14).equals("x-") )
-        {
-            String aNewMediaType = aMediaType.substring(0,12) + aMediaType.substring(14);
-            aMediaType = aNewMediaType;
-        }
-
-        return aMediaType.equals(ODFMediaTypes.TEXT_MEDIA_TYPE) ||
-                aMediaType.equals(ODFMediaTypes.GRAPHICS_MEDIA_TYPE) ||
-                aMediaType.equals(ODFMediaTypes.SPREADSHEET_MEDIA_TYPE) ||
-                aMediaType.equals(ODFMediaTypes.PRESENTATION_MEDIA_TYPE) ||
-                aMediaType.equals(ODFMediaTypes.FORMULA_MEDIA_TYPE) ||
-                aMediaType.equals(ODFMediaTypes.CHART_MEDIA_TYPE);
-    }
-    
-    String getMediaType()
-    { 
-        return m_aMediaType;
-    } 
-    
-    Vector<ManifestEntry> getSubDocuments()
-    {
-        return m_aSubDocs;
-    }
 }

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestListener.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestListener.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestListener.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestListener.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,29 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ * 
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ * 
+ * Use is subject to license terms.
+ * 
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ * 
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * 
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+interface ManifestListener {
+    
+    void setMediaType( String aMediaType );
+    
+}

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java Mon Sep 19 05:33:53 2011
@@ -27,9 +27,10 @@ import java.io.InputStream;
 import java.io.PrintStream;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
+import org.odftoolkit.odfdom.pkg.OdfPackage;
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLFilter;
-import org.odftoolkit.odfdom.pkg.OdfPackage;
+
 
 public class MetaInformation {
 
@@ -60,7 +61,7 @@ public class MetaInformation {
         try
         {
             InputStream aInStream = aDocFile.getInputStream(OdfPackage.OdfFile.MANIFEST.getPath());
-            Logger aLogger = new Logger(aDocFile.getBaseURI(),OdfPackage.OdfFile.MANIFEST.getPath(),m_aOut, Logger.INFO);
+            Logger aLogger = new Logger(aDocFile.getBaseURI(),OdfPackage.OdfFile.MANIFEST.getPath(),m_aOut, Logger.LogLevel.INFO);
         
             getInformation( aInStream, aLogger );
         }

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java Mon Sep 19 05:33:53 2011
@@ -25,6 +25,7 @@ package org.odftoolkit.odfvalidator;
 import java.io.File;
 import org.odftoolkit.odfdom.pkg.OdfPackage;
 
+
 /**
  * Validator for Files
  */
@@ -33,12 +34,12 @@ public class ODFFileValidator extends OD
     private File m_aFile = null;
 
         /** Creates a new instance of ODFFileValidator */
-    public ODFFileValidator( File aFile, int nLogLevel, 
-                             int nMode, String aVersion,
+    public ODFFileValidator( File aFile, Logger.LogLevel nLogLevel,
+                             OdfValidatorMode eMode, OdfVersion aVersion,
                              SAXParseExceptionFilter aFilter,
                              ODFValidatorProvider aValidatorProvider ) throws ODFValidatorException
     {
-        super( nLogLevel, nMode, aVersion, aFilter, aValidatorProvider );
+        super( nLogLevel, eMode, aVersion, aFilter, aValidatorProvider );
         m_aFile = aFile;
     }
 
@@ -46,7 +47,7 @@ public class ODFFileValidator extends OD
     {
         return m_aFile.getAbsolutePath();
     }
-
+    
     protected OdfPackage getPackage() throws Exception
     {
         return OdfPackage.loadPackage( m_aFile );

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFPackageValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFPackageValidator.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFPackageValidator.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFPackageValidator.java Mon Sep 19 05:33:53 2011
@@ -26,7 +26,7 @@ import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
 import java.util.Iterator;
-import java.util.Vector;
+import java.util.Set;
 import java.util.zip.ZipException;
 import javax.xml.parsers.SAXParser;
 import javax.xml.parsers.SAXParserFactory;
@@ -39,47 +39,37 @@ import org.odftoolkit.odfdom.pkg.manifes
 import org.xml.sax.InputSource;
 import org.xml.sax.XMLFilter;
 import org.xml.sax.XMLReader;
+
 import org.xml.sax.helpers.DefaultHandler;
 
 /**
  * Validator for Files
  */
-public abstract class ODFPackageValidator implements MetaInformationListener {
-
-    static final int CHECK_CONFORMANCE = 0; // all versions
-    static final int VALIDATE = 1;          // ODF 1.0 and 1.1 only
-    static final int VALIDATE_STRICT = 2;   // ODF 1.0 and 1.1 only
-    static final int CHECK_EXTENDED_CONFORMANCE = 3; // ODF 1.2 only
-
-    static final String ODF_VERSION_10 = "1.0";
-    static final String ODF_VERSION_11 = "1.1";
-    static final String ODF_VERSION_12 = "1.2";
+public abstract class ODFPackageValidator {
 
     static final String DOCUMENT_SETTINGS = "document-settings";
     static final String DOCUMENT_STYLES = "document-styles";
     static final String DOCUMENT_CONTENT = "document-content";
 
-    private int m_nLogLevel;
-    private int m_nMode = CHECK_CONFORMANCE;
-    private SAXParseExceptionFilter m_aFilter = null;
-    private ODFValidatorProvider m_aValidatorProvider = null;
-    
-    private String m_aMediaType = "";
-    private String m_aGenerator = "";
-    private String m_aConfigVersion = "";
-    private Vector<ManifestEntry> m_aSubDocs;
+    protected Logger.LogLevel m_nLogLevel;
+    protected OdfValidatorMode m_eMode = OdfValidatorMode.CHECK_CONFORMANCE;
+    protected SAXParseExceptionFilter m_aFilter = null;
+    protected ODFValidatorProvider m_aValidatorProvider = null;
+
+    protected ODFValidationResult m_aResult = null;
+    protected OdfVersion m_aConfigVersion = null;
 
     private SAXParserFactory m_aSAXParserFactory = null;
 
 
-    ODFPackageValidator( int nLogLevel, int nMode, String aVersion, String aMediaType,
+    ODFPackageValidator( Logger.LogLevel nLogLevel, OdfValidatorMode eMode, OdfVersion aVersion,
                              SAXParseExceptionFilter aFilter,ODFValidatorProvider aValidatorProvider) {
         m_nLogLevel = nLogLevel;
-        m_nMode = nMode;
+        m_eMode = eMode;
         m_aFilter = aFilter;
         m_aValidatorProvider = aValidatorProvider;
-        m_aMediaType = aMediaType;
         m_aConfigVersion = aVersion;
+        m_aResult = new ODFValidationResult( aVersion, eMode );
     }
     
        
@@ -88,8 +78,6 @@ public abstract class ODFPackageValidato
     
     abstract OdfPackage getPackage( Logger aLogger );
     
-    abstract boolean isRootPackage();
-    
     abstract String getStreamName( String aEntry );
     
     public boolean validate(PrintStream aOut) throws ODFValidatorException
@@ -102,49 +90,24 @@ public abstract class ODFPackageValidato
         if( aPkg == null )
             return true;
 
-        boolean bRoot = isRootPackage();
-        if( bRoot ) 
-            validateMimetype( aOut );
-        
         try
         {
             String aDocVersion = getVersion( aLogger );
             if( aDocVersion != null )
                 aLogger.logInfo( "ODF Version: " + aDocVersion, false );
-            String aVersion = m_aConfigVersion == null ? aDocVersion : m_aConfigVersion;
-            
+            OdfVersion aVersion = m_aConfigVersion == null ? OdfVersion.valueOf(aDocVersion,true) : m_aConfigVersion;
+
+            bHasErrors |= validatePre(aOut, aVersion);
+            aLogger.logInfo( "Media Type: " + m_aResult.getMediaType(), false);
+
             bHasErrors |= validateMeta(aOut, getStreamName( OdfDocument.OdfXMLFile.META.getFileName()), aVersion, true );
-            if( bRoot )
-                bHasErrors |= validateManifest(aOut, aVersion  );
-            aLogger.logInfo( "Media Type: " + m_aMediaType , false);
             bHasErrors |= validateEntry(aOut, getStreamName(OdfDocument.OdfXMLFile.SETTINGS.getFileName()), DOCUMENT_SETTINGS, aVersion);
             bHasErrors |= validateEntry(aOut, getStreamName( OdfDocument.OdfXMLFile.STYLES.getFileName()), DOCUMENT_STYLES, aVersion );
-            if( m_aMediaType.equals(ODFMediaTypes.FORMULA_MEDIA_TYPE))
+            if( m_aResult.getMediaType().equals(ODFMediaTypes.FORMULA_MEDIA_TYPE))
                 bHasErrors |= validateMathML(aOut, getStreamName( OdfDocument.OdfXMLFile.CONTENT.getFileName()), aVersion );
             else
                 bHasErrors |= validateEntry(aOut, getStreamName( OdfDocument.OdfXMLFile.CONTENT.getFileName()), DOCUMENT_CONTENT, aVersion );
-            
-            if( bRoot )
-            {
-                if(m_aSubDocs != null )
-                {
-                    Iterator<ManifestEntry> aIter = m_aSubDocs.iterator();
-                    while( aIter.hasNext() )
-                    {
-                        ManifestEntry aEntry = aIter.next();
-                        ODFPackageValidator aPackageValidator = 
-                            new ODFSubPackageValidator( aPkg, getLoggerName(), aEntry.m_aFullPath, aEntry.m_aMediaType,
-                                                  m_nLogLevel, m_nMode, m_aConfigVersion, m_aFilter, m_aGenerator, m_aValidatorProvider );
-                        bHasErrors |= aPackageValidator.validate(aOut);
-                    }
-                }
-
-                if( aVersion.equals(ODF_VERSION_12))
-                {
-                    bHasErrors |= validateDSig( aOut, OdfPackageExt.STREAMNAME_DOCUMENT_SIGNATURES, aVersion );
-                    bHasErrors |= validateDSig( aOut, OdfPackageExt.STREAMNAME_MACRO_SIGNATURES, aVersion );
-                }
-            }
+            bHasErrors |= validatePost(aOut, aLogger, aVersion);
         }
         catch( ZipException e )
         {
@@ -154,56 +117,60 @@ public abstract class ODFPackageValidato
         {
             aLogger.logFatalError( e.getMessage() );
         }
-        
-        if( bRoot )
-        {
-            if( bHasErrors || aLogger.hasError() )
-            {
-                aLogger.logInfo( "validation errors found" , true );
-                if( m_nLogLevel < Logger.INFO )
-                    aLogger.logInfo( "Generator: " + m_aGenerator , true );
-            }
-            else
-                aLogger.logInfo(  "no errors" , false);  
-        }
+
+        logSummary( bHasErrors, aLogger );
             
         return bHasErrors || aLogger.hasError();
     }
-    
-    protected boolean validateEntry(PrintStream aOut, String aEntryName, String aLocalElementName, String aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
+
+    protected boolean validatePre(PrintStream aOut, OdfVersion aVersion ) throws ODFValidatorException, IOException
+    {
+        return false;
+    }
+
+    protected boolean validatePost(PrintStream aOut, Logger aLogger, OdfVersion aVersion ) throws ODFValidatorException, IOException
+    {
+        return false;
+    }
+
+    protected void logSummary( boolean bHasErrors, Logger aLogger )
+    {
+    }
+
+    protected boolean validateEntry(PrintStream aOut, String aEntryName, String aLocalElementName, OdfVersion aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
     {
         Logger aLogger = new Logger(getLoggerName(),aEntryName,aOut, m_nLogLevel);
         XMLFilter aFilter = new ContentFilter(aLogger, aLocalElementName );
-        if( (m_nMode == CHECK_CONFORMANCE && (aVersion.equals(ODF_VERSION_10) || aVersion.equals(ODF_VERSION_11))) ||
-            m_nMode == CHECK_EXTENDED_CONFORMANCE )
+        if( (m_eMode == OdfValidatorMode.CHECK_CONFORMANCE && aVersion.compareTo(OdfVersion.V1_1) <= 0) ||
+            m_eMode == OdfValidatorMode.CHECK_EXTENDED_CONFORMANCE )
         {
-            XMLFilter aAlienFilter = new AlienFilter(aLogger,aVersion);
+            XMLFilter aAlienFilter = new ForeignContentFilter(aLogger,aVersion,m_aResult);
             aAlienFilter.setParent(aFilter);
             aFilter = aAlienFilter;
         }
-        Validator aValidator = m_nMode == VALIDATE_STRICT ? m_aValidatorProvider.getStrictValidator(aOut, aVersion)
+        Validator aValidator = m_eMode == OdfValidatorMode.VALIDATE_STRICT ? m_aValidatorProvider.getStrictValidator(aOut, aVersion)
                                                           : m_aValidatorProvider.getValidator(aOut,aVersion);
         return validateEntry(aOut, aFilter, aValidator, aLogger, aEntryName );
     }
 
-    private boolean validateMeta(PrintStream aOut, String aEntryName, String aVersion, boolean bIsRoot) throws IOException, ZipException, IllegalStateException, ODFValidatorException
+    private boolean validateMeta(PrintStream aOut, String aEntryName, OdfVersion aVersion, boolean bIsRoot) throws IOException, ZipException, IllegalStateException, ODFValidatorException
     {
         Logger aLogger = new Logger(getLoggerName(),aEntryName,aOut, m_nLogLevel);
-        XMLFilter aFilter = new MetaFilter(aLogger, this );
-        if( (m_nMode == CHECK_CONFORMANCE && (aVersion.equals(ODF_VERSION_10) || aVersion.equals(ODF_VERSION_11))) ||
-            m_nMode == CHECK_EXTENDED_CONFORMANCE )
+        XMLFilter aFilter = new MetaFilter(aLogger, m_aResult );
+        if( (m_eMode == OdfValidatorMode.CHECK_CONFORMANCE && aVersion.compareTo(OdfVersion.V1_1) <= 0) ||
+            m_eMode == OdfValidatorMode.CHECK_EXTENDED_CONFORMANCE )
         {
-            XMLFilter aAlienFilter = new AlienFilter(aLogger,aVersion);
+            XMLFilter aAlienFilter = new ForeignContentFilter(aLogger,aVersion,m_aResult);
             aAlienFilter.setParent(aFilter);
             aFilter = aAlienFilter;
         }
 
-        Validator aValidator = m_nMode == VALIDATE_STRICT ? m_aValidatorProvider.getStrictValidator(aOut,aVersion)
+        Validator aValidator = m_eMode == OdfValidatorMode.VALIDATE_STRICT ? m_aValidatorProvider.getStrictValidator(aOut,aVersion)
                                                           : m_aValidatorProvider.getValidator(aOut,aVersion);
         return validateEntry(aOut, aFilter, aValidator, aLogger, aEntryName );
     }
 
-    private boolean validateMathML(PrintStream aOut, String aEntryName, String aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
+    private boolean validateMathML(PrintStream aOut, String aEntryName, OdfVersion aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
     {
         Logger aLogger = new Logger(getLoggerName(),aEntryName,aOut, m_nLogLevel);
         String aMathMLDTDSystemId = m_aValidatorProvider.getMathMLDTDSystemId(aVersion);
@@ -224,29 +191,8 @@ public abstract class ODFPackageValidato
         }
     }
     
-    private boolean validateManifest(PrintStream aOut, String aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
-    {
-        boolean bRet;
-        Logger aLogger = new Logger(getLoggerName(),OdfPackage.OdfFile.MANIFEST.getPath(),aOut, m_nLogLevel);
-        ManifestFilter aFilter = new ManifestFilter(aLogger);
-        Validator aManifestValidator = m_aValidatorProvider.getManifestValidator(aOut,aVersion);
-        if( aManifestValidator != null )
-        {
-            bRet = validateEntry(aOut, aFilter, 
-                         aManifestValidator, aLogger, OdfPackage.OdfFile.MANIFEST.getPath() );
-        }
-        else
-        {
-            aLogger.logInfo( "Validation of " + OdfPackage.OdfFile.MANIFEST.getPath() + " skipped.", false);
-            bRet = parseEntry(aOut, aFilter, aLogger, OdfPackage.OdfFile.MANIFEST.getPath() , false);
-        }
-        
-        m_aSubDocs = aFilter.getSubDocuments();
-        m_aMediaType = aFilter.getMediaType();
-        return bRet;
-    }
 
-    protected boolean validateDSig(PrintStream aOut, String aEntryName, String aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
+    protected boolean validateDSig(PrintStream aOut, String aEntryName, OdfVersion aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
     {
         Validator aValidator=m_aValidatorProvider.getDSigValidator(aOut,aVersion);
         Logger aLogger = new Logger(getLoggerName(),aEntryName,aOut, m_nLogLevel);
@@ -258,9 +204,8 @@ public abstract class ODFPackageValidato
         return validateEntry(aOut, new DSigFilter(aLogger), aValidator, aLogger, aEntryName );
     }
 
-    private boolean validateEntry(PrintStream aOut, XMLFilter aFilter, 
-                           javax.xml.validation.Validator aValidator,
-                           Logger aLogger,
+    protected boolean validateEntry(PrintStream aOut, XMLFilter aFilter,
+                           Validator aValidator, Logger aLogger,
                            String aEntryName ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
     {
         OdfPackage aPkg = getPackage(aLogger);
@@ -344,11 +289,42 @@ public abstract class ODFPackageValidato
             aLogger.logFatalError(e.getMessage());
         }
         
-        aLogger.logInfo( aLogger.hasError() ? "validation errors found" : "no errors" , false);            
+        aLogger.logInfo( aLogger.hasError() ? "validation errors found" : "no errors" , false);
+        if( m_aResult.hasForeignElements())
+        {
+            Set<String> aForeignElementURISet = m_aResult.getForeignElements().keySet();
+            StringBuilder aBuffer = new StringBuilder();
+            Iterator<String> aIter = aForeignElementURISet.iterator();
+            boolean bFirst = true;
+            while( aIter.hasNext() )
+            {
+                String aURI = aIter.next();
+                aBuffer.setLength(0);
+                aBuffer.append( m_aResult.getForeignElements().get(aURI) );
+                aBuffer.append( " extension elements from the following namespace were found: " );
+                aBuffer.append( aURI );
+                aLogger.logInfo(aBuffer.toString(), false);
+            }
+        }
+        if( m_aResult.hasForeignAttributes())
+        {
+            Set<String> aForeignAttributeURISet = m_aResult.getForeignAttributes().keySet();
+            Iterator<String> aIter = aForeignAttributeURISet.iterator();
+            StringBuilder aBuffer = new StringBuilder();
+            while( aIter.hasNext() )
+            {
+                String aURI = aIter.next();
+                aBuffer.setLength(0);
+                aBuffer.append( m_aResult.getForeignAttributes().get(aURI) );
+                aBuffer.append( " extension attributes from the following namespace were found: " );
+                aBuffer.append( aURI );
+                aLogger.logInfo(aBuffer.toString(), false);
+            }
+        }
         return aLogger.hasError();
     }
 
-    private boolean parseEntry(PrintStream aOut, XMLFilter aFilter, 
+    protected boolean parseEntry(PrintStream aOut, XMLFilter aFilter,
                            Logger aLogger,
                            String aEntryName , boolean bValidating) throws IOException, ZipException, IllegalStateException, ODFValidatorException
     {
@@ -427,46 +403,6 @@ public abstract class ODFPackageValidato
         return false;
     }
     
-    private boolean validateMimetype( PrintStream aOut )
-    {
-        Logger aLogger = new Logger(getLoggerName(),"MIMETYPE",aOut, m_nLogLevel);
-        
-        String aMimetype=getPackage(aLogger).getMediaType();
-        if( (aMimetype == null) || aMimetype.length() == 0 ) {
-            aLogger.logFatalError("file is not a zip file, or has no mimetype.");
-            return true;
-        }
-            
-        if( !(aMimetype.equals(ODFMediaTypes.TEXT_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.TEXT_TEMPLATE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.GRAPHICS_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.GRAPHICS_TEMPLATE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.PRESENTATION_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.SPREADSHEET_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.SPREADSHEET_TEMPLATE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.CHART_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.CHART_TEMPLATE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.IMAGE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.IMAGE_TEMPLATE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.FORMULA_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.FORMULA_TEMPLATE_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.TEXT_MASTER_MEDIA_TYPE)
-            || aMimetype.equals(ODFMediaTypes.TEXT_WEB_MEDIA_TYPE) ) ) {
-                aLogger.logInfo("mimetype is not an ODFMediaTypes mimetype.",false);
-                return true;
-        }
-      
-        /* TODO: not supported by ODFDOM
-        if ( aDocFile .isMimeTypeValid() ) {
-            aLogger.logInfo("no errors",false);
-        } else {
-            aLogger.logError("file is not the first file in the ODF package or is compressed.");
-            return true;
-        }
-        */
-        
-        return false;
-    }
         
     private SAXParser getSAXParser(boolean bValidating) throws ODFValidatorException
     {
@@ -495,20 +431,10 @@ public abstract class ODFPackageValidato
     }
 
     /**
-     * set the generator
-     */ 
-    public void setGenerator(String aGenerator) 
-    {
-        m_aGenerator = aGenerator;
-        if( m_aFilter != null )
-            m_aFilter.setGenerator(m_aGenerator);
-    }
-
-    /**
      * get the generator
      */
     public String getGenerator() {
-        return m_aGenerator;
+        return m_aResult.getGenerator();
     }
 
     private String getVersion(Logger aLogger) throws ODFValidatorException

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFRootPackageValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFRootPackageValidator.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFRootPackageValidator.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFRootPackageValidator.java Mon Sep 19 05:33:53 2011
@@ -23,14 +23,21 @@
 package org.odftoolkit.odfvalidator;
 
 import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Iterator;
+import java.util.Vector;
+import java.util.zip.ZipException;
+import javax.xml.validation.Validator;
 import org.odftoolkit.odfdom.pkg.OdfPackage;
 
-public abstract class ODFRootPackageValidator extends ODFPackageValidator {
+public abstract class ODFRootPackageValidator extends ODFPackageValidator implements ManifestEntryListener {
 
     private OdfPackage m_aPkg = null;
+    private Vector<ManifestEntry> m_aSubDocs = null;
 
-    ODFRootPackageValidator(int nLogLevel, int nMode, String aVersion, SAXParseExceptionFilter aFilter, ODFValidatorProvider aValidatorProvider) {
-        super(nLogLevel, nMode, aVersion, null, aFilter, aValidatorProvider);
+
+    ODFRootPackageValidator(Logger.LogLevel nLogLevel, OdfValidatorMode eMode, OdfVersion aVersion, SAXParseExceptionFilter aFilter, ODFValidatorProvider aValidatorProvider) {
+        super(nLogLevel, eMode, aVersion, aFilter, aValidatorProvider);
     }
 
     abstract OdfPackage getPackage() throws Exception;
@@ -53,13 +60,128 @@ public abstract class ODFRootPackageVali
         return m_aPkg;
     }
 
-    boolean isRootPackage() {
-        return true;
-    }
-
     String getStreamName( String aEntry )
     {
         return aEntry;
     }
 
+    @Override
+    protected boolean validatePre(PrintStream aOut, OdfVersion aVersion ) throws ODFValidatorException, IOException
+    {
+        boolean bErrorsFound = validateMimetype( aOut );
+        bErrorsFound |= validateManifest(aOut, aVersion  );
+
+        return bErrorsFound;
+    }
+
+    @Override
+    protected boolean validatePost(PrintStream aOut,Logger aLogger,OdfVersion aVersion ) throws ODFValidatorException, IOException
+    {
+        boolean bHasErrors = false;
+        if(m_aSubDocs != null )
+        {
+            Iterator<ManifestEntry> aIter = m_aSubDocs.iterator();
+            while( aIter.hasNext() )
+            {
+                ManifestEntry aEntry = aIter.next();
+                ODFPackageValidator aPackageValidator =
+                    new ODFSubPackageValidator( getPackage(aLogger), getLoggerName(), aEntry.getFullPath(), aEntry.getMediaType(),
+                                                  m_nLogLevel, m_eMode, m_aConfigVersion, m_aFilter, m_aResult.getGenerator(), m_aValidatorProvider );
+                bHasErrors |= aPackageValidator.validate(aOut);
+            }
+        }
+
+        if( aVersion.compareTo(OdfVersion.V1_2) >= 0 )
+        {
+            bHasErrors |= validateDSig( aOut, OdfPackageExt.STREAMNAME_DOCUMENT_SIGNATURES, aVersion );
+            bHasErrors |= validateDSig( aOut, OdfPackageExt.STREAMNAME_MACRO_SIGNATURES, aVersion );
+        }
+
+        return bHasErrors;
+    }
+
+    @Override
+    protected void logSummary( boolean bHasErrors, Logger aLogger )
+    {
+        if( bHasErrors || aLogger.hasError() )
+        {
+            aLogger.logInfo( "validation errors found" , true );
+            if( m_nLogLevel.compareTo(Logger.LogLevel.INFO) < 0 )
+                aLogger.logInfo( "Generator: " + m_aResult.getGenerator() , true );
+        }
+        else
+            aLogger.logInfo(  "no errors" , false);
+    }
+
+
+    public void foundManifestEntry( ManifestEntry aManifestEntry )
+    {
+        if( aManifestEntry.isOpenDocumentMediaType() )
+        {
+            if( m_aSubDocs == null )
+                m_aSubDocs = new Vector<ManifestEntry>();
+            m_aSubDocs.add( aManifestEntry );
+        }
+    }
+
+    private boolean validateMimetype( PrintStream aOut )
+    {
+        Logger aLogger = new Logger(getLoggerName(),"MIMETYPE",aOut, m_nLogLevel);
+
+        String aMimetype=getPackage(aLogger).getMediaType();
+        if( (aMimetype == null) || aMimetype.length() == 0 ) {
+            aLogger.logFatalError("file is not a zip file, or has no mimetype.");
+            return true;
+        }
+
+        if( !(aMimetype.equals(ODFMediaTypes.TEXT_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.TEXT_TEMPLATE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.GRAPHICS_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.GRAPHICS_TEMPLATE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.PRESENTATION_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.SPREADSHEET_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.SPREADSHEET_TEMPLATE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.CHART_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.CHART_TEMPLATE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.IMAGE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.IMAGE_TEMPLATE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.FORMULA_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.FORMULA_TEMPLATE_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.TEXT_MASTER_MEDIA_TYPE)
+            || aMimetype.equals(ODFMediaTypes.TEXT_WEB_MEDIA_TYPE) ) ) {
+                aLogger.logInfo("mimetype is not an ODFMediaTypes mimetype.",false);
+                return true;
+        }
+
+        /* TODO: not supported by ODFDOM
+        if ( aDocFile .isMimeTypeValid() ) {
+            aLogger.logInfo("no errors",false);
+        } else {
+            aLogger.logError("file is not the first file in the ODF package or is compressed.");
+            return true;
+        }
+        */
+
+        return false;
+    }
+
+    private boolean validateManifest(PrintStream aOut, OdfVersion aVersion ) throws IOException, ZipException, IllegalStateException, ODFValidatorException
+    {
+        boolean bRet;
+        Logger aLogger = new Logger(getLoggerName(),OdfPackage.OdfFile.MANIFEST.getPath(),aOut, m_nLogLevel);
+        ManifestFilter aFilter = new ManifestFilter(aLogger,m_aResult, this);
+        Validator aManifestValidator = m_aValidatorProvider.getManifestValidator(aOut,aVersion);
+        if( aManifestValidator != null )
+        {
+            bRet = validateEntry(aOut, aFilter,
+                         aManifestValidator, aLogger, OdfPackage.OdfFile.MANIFEST.getPath() );
+        }
+        else
+        {
+            aLogger.logInfo( "Validation of " + OdfPackage.OdfFile.MANIFEST.getPath() + " skipped.", false);
+            bRet = parseEntry(aOut, aFilter, aLogger, OdfPackage.OdfFile.MANIFEST.getPath() , false);
+        }
+        return bRet;
+    }
+
 }

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFStreamValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFStreamValidator.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFStreamValidator.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFStreamValidator.java Mon Sep 19 05:33:53 2011
@@ -23,9 +23,10 @@
 package org.odftoolkit.odfvalidator;
 
 import java.io.InputStream;
-
 import org.odftoolkit.odfdom.pkg.OdfPackage;
 
+
+
 /**
  * Validator for Streams
  */
@@ -36,14 +37,14 @@ public class ODFStreamValidator extends 
 
     ODFStreamValidator(InputStream aInputStream,
                               String aBaseURI,
-                              int nLogLevel, 
-                              int nMode,
-                              String aVersion,
+                              Logger.LogLevel nLogLevel,
+                              OdfValidatorMode eMode,
+                              OdfVersion aVersion,
                               SAXParseExceptionFilter aFilter,
                               ODFValidatorProvider aValidatorProvider ) 
         
         throws ODFValidatorException {
-        super(nLogLevel, nMode, aVersion, aFilter, aValidatorProvider );
+        super(nLogLevel, eMode, aVersion, aFilter, aValidatorProvider );
         
         m_aInputStream=aInputStream;
         m_aBaseURI=aBaseURI;

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFSubPackageValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFSubPackageValidator.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFSubPackageValidator.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFSubPackageValidator.java Mon Sep 19 05:33:53 2011
@@ -24,6 +24,7 @@ package org.odftoolkit.odfvalidator;
 
 import org.odftoolkit.odfdom.pkg.OdfPackage;
 
+
 public class ODFSubPackageValidator extends ODFPackageValidator {
 
     private OdfPackage m_aPkg = null;
@@ -31,14 +32,15 @@ public class ODFSubPackageValidator exte
     private String m_aSubEntryName = null;
 
     ODFSubPackageValidator( OdfPackage aPkg, String aBaseURI, String aSubEntryName, String aMediaType,
-                             int nLogLevel, int nMode, String aVersion,
+                             Logger.LogLevel nLogLevel, OdfValidatorMode eMode, OdfVersion aVersion,
                              SAXParseExceptionFilter aFilter, String aParentGenerator,
                              ODFValidatorProvider aValidatorProvider ) throws ODFValidatorException
     {
-        super( nLogLevel, nMode, aVersion, aMediaType, aFilter, aValidatorProvider );
+        super( nLogLevel, eMode, aVersion, aFilter, aValidatorProvider);
         m_aPkg = aPkg;
         m_aBaseURI = aBaseURI + "/" + aSubEntryName;
         m_aSubEntryName = aSubEntryName;
+        m_aResult.setMediaType(aMediaType);
         if( aFilter != null )
             aFilter.startPackage(aParentGenerator);  // take build id from main document as default (embedded objects can nevern be newer)
     }
@@ -48,11 +50,6 @@ public class ODFSubPackageValidator exte
         return m_aBaseURI;
     }
 
-    boolean isRootPackage()
-    {
-        return false;
-    }
-    
     OdfPackage getPackage( Logger aLogger ) 
     {
         return m_aPkg;

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidationResult.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidationResult.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidationResult.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidationResult.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,135 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+import java.util.HashMap;
+import java.util.Map;
+import org.xml.sax.Attributes;
+
+public class ODFValidationResult implements ManifestListener, MetaInformationListener, ForeignContentListener
+{
+    public enum Status
+    {
+        /**
+         * The document is non conforming to a particular conformance level.
+         */
+        NON_CONFORMING,
+        /**
+         * The document is conforming to a particular conformance level.
+         */
+        CONFORMING,
+        /**
+         * It is unknown whether the document conforms to a particular level.
+         */
+        UNKNOWN,
+        /**
+         * The conformance level is not applicable to the specified file.
+         */
+        NOT_APPLICABLE
+    }
+
+    private String m_aGenerator = null;
+    private String m_aMediaType = null;
+
+    private HashMap<String,Long> m_aForeignElementMap = null;
+    private HashMap<String,Long> m_aForeignAttributeMap = null;
+
+    private Status m_aStrictValid = Status.UNKNOWN;
+    private Status m_aValid = Status.UNKNOWN;
+    private Status m_aConforming = Status.UNKNOWN;
+    private Status m_aExtendedConforming = Status.UNKNOWN;
+
+    private OdfVersion m_aVersion = null;
+    private OdfValidatorMode m_eMode = null;
+
+    ODFValidationResult( OdfVersion aVersion, OdfValidatorMode eMode )
+    {
+        m_aVersion = aVersion;
+        m_eMode = eMode;
+    }
+
+
+    public void setGenerator(String aGenerator)
+    {
+        m_aGenerator = aGenerator;
+    }
+
+    public void setMediaType(String aMediaType)
+    {
+        m_aMediaType = aMediaType;
+    }
+
+    public void foreignElementDetected(String aUri, String aLocalName, String aQName, Attributes aAtts)
+    {
+        if( m_aForeignElementMap == null )
+            m_aForeignElementMap = new HashMap<String,Long>();
+
+        Long aCount = m_aForeignElementMap.get(aUri);
+        if( aCount == null )
+            aCount = Long.valueOf(0);
+        m_aForeignElementMap.put(aUri, aCount+1);
+    }
+
+    public void foreignAttributeDetected(String aUri, String aLocalName, String aQName, String aValue)
+    {
+        if( m_aForeignAttributeMap == null )
+            m_aForeignAttributeMap = new HashMap<String,Long>();
+
+        Long aCount = m_aForeignAttributeMap.get(aUri);
+        if( aCount == null )
+            aCount = Long.valueOf(0);
+        m_aForeignAttributeMap.put(aUri, aCount+1);
+    }
+
+
+    public String getGenerator()
+    {
+        return m_aGenerator;
+    }
+
+    public String getMediaType()
+    {
+        return m_aMediaType;
+    }
+
+    public boolean hasForeignElements()
+    {
+        return m_aForeignElementMap != null;
+    }
+
+    public Map<String,Long> getForeignElements()
+    {
+        return m_aForeignElementMap;
+    }
+
+    public boolean hasForeignAttributes()
+    {
+        return m_aForeignAttributeMap != null;
+    }
+
+    public Map<String,Long> getForeignAttributes()
+    {
+        return m_aForeignAttributeMap;
+    }
+
+}

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidator.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidator.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidator.java Mon Sep 19 05:33:53 2011
@@ -43,7 +43,7 @@ public class ODFValidator implements ODF
     // Prefix used to distinguish internal resources from external ones
     
     // Loglevel
-    private int m_nLogLevel;
+    private Logger.LogLevel m_nLogLevel;
 
     // Validator provider
     private SchemaFactory m_aRNGSchemaFactory = null;
@@ -53,22 +53,22 @@ public class ODFValidator implements ODF
     protected Configuration m_aConfig = null;
     
     // User provided ODF version
-    protected String m_aVersion = null;
+    protected OdfVersion m_aVersion = null;
     
     // User provided preference for using Math DTD
     protected boolean m_bUseMathDTD = false;
 
     // Validatore and configuration cache
     private HashMap<String,Validator> m_aValidatorMap = null;
-    private HashMap<String,Configuration> m_aConfigurationMap = null;
+    private HashMap<OdfVersion,Configuration> m_aConfigurationMap = null;
 
     // Generator from last validateFile or validateStream call
     private String m_aGenerator = "";
 
     /** Creates a new instance of Validator */
     public ODFValidator( Configuration aConfig,
-                         int nLogLevel,
-                         String aVersion,
+                         Logger.LogLevel nLogLevel,
+                         OdfVersion aVersion,
                          boolean bUseMathDTD ) throws ODFValidatorException {
         
         m_nLogLevel = nLogLevel;
@@ -77,7 +77,7 @@ public class ODFValidator implements ODF
         m_bUseMathDTD = bUseMathDTD;
     }    
     
-    public boolean validate(PrintStream aOut, Configuration aConfig, int nMode ) throws ODFValidatorException
+    public boolean validate(PrintStream aOut, Configuration aConfig, OdfValidatorMode eMode ) throws ODFValidatorException
     {
         List<String> aFileNames = aConfig.getListPropety(Configuration.PATH);
         String aExcludeRegExp = aConfig.getProperty(Configuration.EXCLUDE);
@@ -85,12 +85,12 @@ public class ODFValidator implements ODF
         boolean bRecursive = aRecursive != null ? Boolean.valueOf(aRecursive) : false;
         String aFilterFileName = aConfig.getProperty(Configuration.FILTER);
 
-        return validate(aOut, aFileNames, aExcludeRegExp, nMode, bRecursive, aFilterFileName );
+        return validate(aOut, aFileNames, aExcludeRegExp, eMode, bRecursive, aFilterFileName );
     }
 
 
     public boolean validate(PrintStream aOut, List<String> aFileNames, String aExcludeRegExp, 
-                            int nMode, boolean bRecursive,                            
+                            OdfValidatorMode eMode, boolean bRecursive,
                             String aFilterFileName ) throws ODFValidatorException
     {
         boolean bRet = false;
@@ -105,22 +105,22 @@ public class ODFValidator implements ODF
         while( aIter.hasNext() )
         {
             File aFile = new File( aIter.next() );
-            bRet |= aFile.isDirectory() ? validateDir(aOut, aFile, aFileFilter, nMode, aFilter )
-                : validateFile(aOut, aFile, nMode, aFilter );
+            bRet |= aFile.isDirectory() ? validateDir(aOut, aFile, aFileFilter, eMode, aFilter )
+                : validateFile(aOut, aFile, eMode, aFilter );
         }
         
         return bRet;
     }
     
     public boolean validate(PrintStream aOut, InputStream aInputStream, String aBaseURI,
-                            int nMode,
+                            OdfValidatorMode eMode,
                             SAXParseExceptionFilter aFilter ) throws ODFValidatorException
     {
-        return validateStream( aOut, aInputStream, aBaseURI, nMode, aFilter );
+        return validateStream( aOut, aInputStream, aBaseURI, eMode, aFilter );
     }
     
 
-    private boolean validateDir(PrintStream aOut, final File aDir, FileFilter aFileFilter, int nMode, SAXParseExceptionFilter aFilter ) throws ODFValidatorException 
+    private boolean validateDir(PrintStream aOut, final File aDir, FileFilter aFileFilter, OdfValidatorMode eMode, SAXParseExceptionFilter aFilter ) throws ODFValidatorException
     {
         boolean bRet = true;
         File[] aFiles = aDir.listFiles( aFileFilter );
@@ -132,11 +132,11 @@ public class ODFValidator implements ODF
                 File aFile = aFiles[i];
                 if( aFile.isDirectory() )
                 {
-                    bRet |= validateDir(aOut, aFile, aFileFilter, nMode, aFilter );
+                    bRet |= validateDir(aOut, aFile, aFileFilter, eMode, aFilter );
                 }
                 else
                 {
-                    bRet |= validateFile(aOut, aFile, nMode, aFilter );
+                    bRet |= validateFile(aOut, aFile, eMode, aFilter );
                 }
             }
         }
@@ -148,10 +148,10 @@ public class ODFValidator implements ODF
      *
      * <p>After validation the getGenerator method can be called to get the generator of the validated file</p>
      */
-    public boolean validateFile(PrintStream aOut, File aDocFile, int nMode, SAXParseExceptionFilter aFilter ) throws ODFValidatorException
+    public boolean validateFile(PrintStream aOut, File aDocFile, OdfValidatorMode eMode, SAXParseExceptionFilter aFilter ) throws ODFValidatorException
     {
         ODFFileValidator aFileValidator = 
-            new ODFFileValidator( aDocFile, m_nLogLevel, nMode, m_aVersion, aFilter, this );
+            new ODFFileValidator( aDocFile, m_nLogLevel, eMode, m_aVersion, aFilter, this );
         
         boolean result=aFileValidator.validate(aOut);
 
@@ -165,11 +165,11 @@ public class ODFValidator implements ODF
      * <p>After validation the getGenerator method can be called to get the generator of the validated file</p>
      */
     public boolean validateStream(PrintStream aOut, InputStream aInputStream, String aBaseURI,
-                                  int nMode,
+                                  OdfValidatorMode eMode,
                                   SAXParseExceptionFilter aFilter ) throws ODFValidatorException
     {
         ODFStreamValidator aStreamValidator = 
-            new ODFStreamValidator( aInputStream, aBaseURI, m_nLogLevel, nMode, m_aVersion, aFilter, this );
+            new ODFStreamValidator( aInputStream, aBaseURI, m_nLogLevel, eMode, m_aVersion, aFilter, this );
 
         boolean result=aStreamValidator.validate(aOut);
         m_aGenerator=aStreamValidator.getGenerator();
@@ -177,27 +177,27 @@ public class ODFValidator implements ODF
         return result;
     }
 
-    public Validator getManifestValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    public Validator getManifestValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException
     {
         return getValidatorForSchema( aOut, getSchemaFileName(Configuration.MANIFEST_SCHEMA,aVersion));
     }
     
-    public Validator getValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    public Validator getValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException
     {
         return getValidatorForSchema( aOut, getSchemaFileName(Configuration.SCHEMA,aVersion));
     }
     
-    public Validator getStrictValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    public Validator getStrictValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException
     {
         return getValidatorForSchema( aOut, getSchemaFileName(Configuration.STRICT_SCHEMA,aVersion));
     }
     
-    public Validator getMathMLValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    public Validator getMathMLValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException
     {
         return getValidatorForSchema( aOut, getSchemaFileName(Configuration.MATHML2_SCHEMA,aVersion));
     }
     
-    public String getMathMLDTDSystemId( String aVersion ) throws ODFValidatorException
+    public String getMathMLDTDSystemId( OdfVersion aVersion ) throws ODFValidatorException
     {
         String aDTD = null;
         if( m_bUseMathDTD )
@@ -213,7 +213,7 @@ public class ODFValidator implements ODF
         return aDTD;
     }
     
-    public Validator getDSigValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    public Validator getDSigValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException
     {
         return getValidatorForSchema( aOut, getSchemaFileName(Configuration.DSIG_SCHEMA,aVersion));
     }
@@ -225,7 +225,7 @@ public class ODFValidator implements ODF
         m_aValidatorMap = null;
     }
 
-    private String getSchemaFileName( String aConfigName, String aVersion) throws ODFValidatorException
+    private String getSchemaFileName( String aConfigName, OdfVersion aVersion) throws ODFValidatorException
     {
         Configuration aConfig = 
             m_aConfig != null ? m_aConfig : getConfiguration( aVersion );
@@ -237,23 +237,23 @@ public class ODFValidator implements ODF
         return aFileName;
     }
 
-    private Configuration getConfiguration( String aVersion ) throws ODFValidatorException
+    private Configuration getConfiguration( OdfVersion aVersion ) throws ODFValidatorException
     {
         if( m_aConfigurationMap == null )
-            m_aConfigurationMap = new HashMap<String,Configuration>();
+            m_aConfigurationMap = new HashMap<OdfVersion,Configuration>();
         
         Configuration aConfig = m_aConfigurationMap.get(aVersion);
         if( aConfig == null)
         {
             String aConfigName = null;
-            if( aVersion == null || aVersion.equals("1.2") )
+            if( aVersion == null || aVersion==OdfVersion.V1_2 )
                 aConfigName = "/config/v12.properties";
-            else if( aVersion.equals("1.1") )
+            else if( aVersion==OdfVersion.V1_1 )
                 aConfigName = "/config/v11.properties";
-            else if( aVersion.equals("1.0") )
+            else if( aVersion==OdfVersion.V1_0 )
                 aConfigName = "/config/v10.properties";
             else
-                throw new ODFValidatorException( "unsupported ODF version: ".concat(aVersion) );
+                throw new ODFValidatorException( "unsupported ODF version: ".concat(aVersion.toString()) );
             
             InputStream aInStream = getClass().getResourceAsStream(aConfigName);
             if( aInStream == null )

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidatorProvider.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidatorProvider.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidatorProvider.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidatorProvider.java Mon Sep 19 05:33:53 2011
@@ -26,17 +26,17 @@ import javax.xml.validation.Validator;
 import java.io.PrintStream;
 
 public interface ODFValidatorProvider {
-    Validator getValidator(PrintStream aOut, String aVersion ) throws ODFValidatorException;
+    Validator getValidator(PrintStream aOut, OdfVersion aVersion ) throws ODFValidatorException;
 
-    Validator getStrictValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+    Validator getStrictValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException;
     
-    Validator getManifestValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+    Validator getManifestValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException;
 
-    Validator getDSigValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+    Validator getDSigValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException;
 
-    Validator getMathMLValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+    Validator getMathMLValidator(PrintStream aOut, OdfVersion aVersion) throws ODFValidatorException;
 
-    String getMathMLDTDSystemId( String aVersion ) throws ODFValidatorException;
+    String getMathMLDTDSystemId( OdfVersion aVersion ) throws ODFValidatorException;
         
     void resetValidatorProvider();
 }

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfValidatorMode.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfValidatorMode.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfValidatorMode.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfValidatorMode.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,45 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+public enum OdfValidatorMode {
+    /***
+     * all versions
+     */
+    CHECK_CONFORMANCE, //
+
+    /***
+     * ODF 1.0 and 1.1 only, equals CHECK_CONFORMANCE for ODF 1.2
+     */
+    VALIDATE,
+
+    /***
+     * ODF 1.0 and 1.1 only, equals CHECK_CONFORMANCE for ODF 1.2
+     */
+    VALIDATE_STRICT,
+
+    /***
+     * ODF 1.2 only, equals CHECK_CONFORMANCE for ODF 1.0/1.1
+     */
+    CHECK_EXTENDED_CONFORMANCE;
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfVersion.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfVersion.java?rev=1172439&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfVersion.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfVersion.java Mon Sep 19 05:33:53 2011
@@ -0,0 +1,57 @@
+/************************************************************************
+ *
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+ *
+ * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
+ *
+ * Use is subject to license terms.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License"); you may not
+ * use this file except in compliance with the License. You may obtain a copy
+ * of the License at http://www.apache.org/licenses/LICENSE-2.0. You can also
+ * obtain a copy of the License at http://odftoolkit.org/docs/license.txt
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ *
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ ************************************************************************/
+
+package org.odftoolkit.odfvalidator;
+
+public enum OdfVersion {
+
+    V1_0( "1.0" ), V1_1( "1.1" ), V1_2( "1.2" );
+
+    private String m_aValue;
+
+    OdfVersion( String _aValue )
+    {
+        m_aValue = _aValue;
+    }
+
+    @Override
+    public String toString()
+    {
+        return m_aValue;
+    }
+
+    public static OdfVersion valueOf( String _aString, boolean _bAttrValue )
+    {
+        if( _aString == null )
+            return _bAttrValue ? V1_1 : null;
+
+        for( OdfVersion aIter : values() )
+        {
+            if( _aString.equals( aIter.toString() ) )
+            {
+                return aIter;
+            }
+        }
+        return _bAttrValue ? V1_1 : null;
+    }
+
+}

Modified: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ValidationOOoTaskIdErrorFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ValidationOOoTaskIdErrorFilter.java?rev=1172439&r1=1172438&r2=1172439&view=diff
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ValidationOOoTaskIdErrorFilter.java (original)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ValidationOOoTaskIdErrorFilter.java Mon Sep 19 05:33:53 2011
@@ -83,11 +83,13 @@ public class ValidationOOoTaskIdErrorFil
             m_aFilterEntries = aFilterEntries;
         }
 
+        @Override
         public void characters(char[] aCh, int nStart, int nLength) throws SAXException {
             if( m_aEntry != null )
                 m_aEntry.m_aMessage += new String(aCh, nStart, nLength);
         }
 
+        @Override
         public void startElement(String aUri, String aLocalName, String aQName, Attributes aAttributes) throws SAXException {
             if( aQName.equals(FILTER_ENTRY) )
             {
@@ -103,6 +105,7 @@ public class ValidationOOoTaskIdErrorFil
             }
         }
 
+        @Override
         public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
             if( aQName.equals(FILTER_ENTRY) )
             {
@@ -120,7 +123,7 @@ public class ValidationOOoTaskIdErrorFil
         m_aFilterEntries = new HashMap<String,FilterEntry>();
         m_aTaskIdsReported = new HashSet<String>();
         SAXParser aParser = null;
-        Logger aLogger = new Logger( aFilterFile.getAbsolutePath(), "", aOut, Logger.ERROR );
+        Logger aLogger = new Logger( aFilterFile.getAbsolutePath(), "", aOut, Logger.LogLevel.ERROR );
         try
         {
             SAXParserFactory aParserFactory = SAXParserFactory.newInstance();



Mime
View raw message