incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1172437 [1/2] - in /incubator/odf/trunk/validator/src: odfvalidator/ org/ org/odftoolkit/ org/odftoolkit/odfvalidator/
Date Mon, 19 Sep 2011 05:32:58 GMT
Author: devinhan
Date: Mon Sep 19 05:32:56 2011
New Revision: 1172437

URL: http://svn.apache.org/viewvc?rev=1172437&view=rev
Log:
changeset:   6:b8bea61a098c
user:        Hans-Peter Schaal
date:        Mon Jul 06 16:07:02 2009 +0200
Resync with odfdom. Integrate into odftoolkit package structure.

Added:
    incubator/odf/trunk/validator/src/org/
    incubator/odf/trunk/validator/src/org/odftoolkit/
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/AlienFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Configuration.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ContentFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/DSigFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/InternalResources.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML101Filter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML20Filter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformationListener.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/NamespaceFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFMediaTypes.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFPackageValidator.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFRootPackageValidator.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFStreamValidator.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFSubPackageValidator.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidator.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidatorException.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFValidatorProvider.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/OdfPackageExt.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/SAXParseExceptionFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/SAXVersionException.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/SchemaErrorHandler.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/SchemaFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/SchemaResourceResolver.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ValidationMessageCollectorErrorFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ValidationOOoTaskIdErrorFilter.java
    incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/VersionHandler.java
Removed:
    incubator/odf/trunk/validator/src/odfvalidator/

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/AlienFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/AlienFilter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/AlienFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/AlienFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,144 @@
+/************************************************************************
+ *
+ * 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.OdfNamespace;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+class AlienFilter extends XMLFilterImpl {
+
+    private static final String OFFICE_NAMESPACE_URI = OdfNamespace.OFFICE.toString();
+    
+    private static final String PROCESS_CONTENT = "process-content";
+    private static final String TRUE_STRING = "true";
+    
+    private static HashSet<String> m_aODFNamespaceSet = null;
+    private Vector<Boolean> m_aAlienElements = null;
+
+    private Logger m_aLogger;
+
+    /** Creates a new instance of NamespaceFilter */
+    AlienFilter( Logger aLogger, String aVersion ) {
+        m_aLogger = aLogger;
+        m_aAlienElements = new Vector<Boolean>();
+        
+        m_aODFNamespaceSet = new HashSet<String>();
+        m_aODFNamespaceSet.add( OdfNamespace.OFFICE.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.STYLE.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.TEXT.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.TABLE.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.DRAW.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.FO.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.DC.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.META.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.NUMBER.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.SVG.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.CHART.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.DR3D.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.FORM.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.PRESENTATION.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.SMIL.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.CONFIG.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.SCRIPT.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.XLINK.toString() );
+        m_aODFNamespaceSet.add( OdfNamespace.XFORMS.toString() );
+        if( aVersion.equals("1.2"))
+        {
+            m_aODFNamespaceSet.add( "http://www.w3.org/1999/xhtml" );
+            m_aODFNamespaceSet.add( "http://www.w3.org/2003/g/data-view#" );
+        }
+
+    }
+
+
+
+    @Override
+    public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
+        if( isAlienNamespace(aUri) )
+        {
+            m_aAlienElements.removeElementAt( m_aAlienElements.size()-1 );
+        }
+        else
+        {
+            boolean bProcessContent = m_aAlienElements.isEmpty() ? true : m_aAlienElements.lastElement();
+            if( bProcessContent )
+                super.endElement(aUri,aLocalName,aQName);
+        }
+    }
+
+
+    @Override
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAtts) throws SAXException {
+        Boolean bProcessContent = m_aAlienElements.isEmpty() ? true : m_aAlienElements.lastElement();
+        
+        if( isAlienNamespace(aUri) )
+        {
+            if( bProcessContent )
+            {
+                String aProcessContentValue = aAtts.getValue( OFFICE_NAMESPACE_URI, PROCESS_CONTENT );
+                bProcessContent = aProcessContentValue == null || aProcessContentValue.equals(TRUE_STRING);
+            }
+            m_aAlienElements.addElement( bProcessContent );
+            m_aLogger.logInfo( String.format("element <%s> ignored, content is %s.",aQName,bProcessContent?"processed":"not processed"), false);            
+        }
+        else if( bProcessContent )
+        {
+            Attributes aOldAtts = aAtts;
+            AttributesImpl aNewAtts = null;
+            int i = aOldAtts.getLength();
+            while( i>0 ) {
+                --i;
+                if ( isAlienNamespace( aOldAtts.getURI(i) ) ) {
+                    if (aNewAtts == null) {
+                        aNewAtts = new AttributesImpl(aOldAtts);
+                        aAtts = aNewAtts;
+                    }
+                    m_aLogger.logInfo( String.format("attribute '%s' of element <%s> ignored.",aAtts.getQName(i),aQName), false);            
+                    aNewAtts.removeAttribute(i);
+                }
+            }
+            super.startElement(aUri, aLocalName, aQName, aAtts);
+        }
+    }
+    
+    
+
+    private boolean isAlienNamespace( String aUri )
+    {
+        return !m_aODFNamespaceSet.contains(aUri);
+    }
+
+    @Override
+    public void characters(char[] aChars, int nStart, int nLength) throws SAXException {
+        boolean bProcessContent = m_aAlienElements.isEmpty() ? true : m_aAlienElements.lastElement();
+        if( bProcessContent )
+            super.characters(aChars, nStart, nLength);
+    }
+    
+    
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Configuration.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Configuration.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Configuration.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Configuration.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,93 @@
+/************************************************************************
+ *
+ * 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.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.Enumeration;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Properties;
+import java.util.TreeSet;
+import java.util.Vector;
+
+public class Configuration extends Properties {
+
+    
+    public static final String SCHEMA = "schema";
+    public static final String STRICT_SCHEMA = "strict-schema";
+    public static final String MANIFEST_SCHEMA = "manifest-schema";
+    public static final String MATHML_SCHEMA = "mathml-schema";
+    public static final String MATHML2_SCHEMA = "mathml2-schema";
+    public static final String DSIG_SCHEMA = "dsig-schema";
+    public static final String PATH = "path";
+    public static final String EXCLUDE = "exclude";
+    public static final String RECURSIVE = "recursive";
+    public static final String FILTER = "filter";
+
+    public static final String VALIDATOR_URL = "validator-url";
+    public static final String PROXY_HOST="proxy-host";
+    public static final String PROXY_PORT="proxy-port";
+
+    /** Creates a new instance of AppProperties */
+    public Configuration()
+    {
+    }
+    
+    public Configuration( File aConfigFile ) throws FileNotFoundException, IOException
+    {
+        FileInputStream aInStream = new FileInputStream( aConfigFile );
+        loadFromXML( aInStream );
+        aInStream.close();
+    }
+    
+
+    public void store( File aConfigFile ) throws FileNotFoundException, IOException 
+    {
+        FileOutputStream aOutStream = new FileOutputStream( aConfigFile );
+        storeToXML( aOutStream, null );
+        aOutStream.close();
+    }
+    
+    public List<String> getListPropety( String aPropNamePrefix )
+    {
+        TreeSet<String> aSortedPropNames = new TreeSet<String>();
+        Enumeration aPropNames = propertyNames();
+        while( aPropNames.hasMoreElements() )
+        {
+            String aPropName = (String)aPropNames.nextElement();
+            if( aPropName.startsWith(aPropNamePrefix))
+                aSortedPropNames.add(aPropName);
+        }
+        
+        List<String> aValues = new Vector<String>(aSortedPropNames.size());
+        Iterator<String> aIter = aSortedPropNames.iterator();
+        while( aIter.hasNext() )
+            aValues.add(getProperty( aIter.next() ) );
+        
+        return aValues;
+    }
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ContentFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ContentFilter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ContentFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ContentFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,112 @@
+/************************************************************************
+ *
+ * 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.odftoolkit.odfdom.dom.OdfNamespace;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+
+class ContentFilter extends NamespaceFilter {
+
+    private static final String CD2_SVG_NAMESPACE_URI = "http://www.w3.org/2000/svg";
+    private static final String CD2_XSL_NAMESPACE_URI = "http://www.w3.org/1999/XSL/Format";
+    private static final String CD2_SMIL_NAMESPACE_URI = "http://www.w3.org/2001/SMIL20/";
+    private static final String BASE_OFFICE_NAMESPACE_URI = "http://openoffice.org/2004/office";
+    private static final String BASE_DB_NAMESPACE_URI = "http://openoffice.org/2004/database";
+    private static final String SVG_NAMESPACE_URI = OdfNamespace.SVG.toString();
+    private static final String XSL_NAMESPACE_URI = OdfNamespace.FO.toString();
+    private static final String SMIL_NAMESPACE_URI = OdfNamespace.SMIL.toString();
+    private static final String DRAW_NAMESPACE_URI = OdfNamespace.DRAW.toString();
+    private static final String OFFICE_NAMESPACE_URI = OdfNamespace.OFFICE.toString();;
+    private static final String DB_NAMESPACE_URI = "urn:oasis:names:tc:opendocument:xmlns:database:1.0";
+    private static final String BASE_OFFICE_NAMESPACE_PREFIX = "office";
+    private static final String POLYGON = "polygon";
+    private static final String CONTOUR_POLYGON = "contour-polygon";
+    private static final String POLYLINE = "polyline";
+    private static final String POINTS = "points";
+    private static final int MAX_POINTS_LEN = 2048;
+        
+    private Logger m_aLogger;
+    private String m_aLocalElementName;
+    private boolean m_bRoot = true;
+    
+    /** Creates a new instance of KnownIssueFilter */
+    ContentFilter( Logger aLogger, String aLocalElementName ) {
+        m_aLogger = aLogger;
+        m_aLocalElementName = aLocalElementName;
+    }
+
+    String adaptNamespaceUri( String aUri, String aPrefix)
+    {
+        String aNewUri = null;
+        if( aUri.equals(CD2_SVG_NAMESPACE_URI) )
+            aNewUri = SVG_NAMESPACE_URI;
+        else if( aUri.equals(CD2_XSL_NAMESPACE_URI) )
+             aNewUri = XSL_NAMESPACE_URI;
+        else if( aUri.equals(CD2_SMIL_NAMESPACE_URI) ) 
+            aNewUri = SMIL_NAMESPACE_URI;
+        else if( aUri.equals(BASE_OFFICE_NAMESPACE_URI) &&
+                 (aPrefix == null || aPrefix.startsWith(BASE_OFFICE_NAMESPACE_PREFIX)) )
+            aNewUri = OFFICE_NAMESPACE_URI;
+        else if( aUri.equals(BASE_DB_NAMESPACE_URI) )
+            aNewUri = DB_NAMESPACE_URI;
+        
+        return aNewUri;
+    }
+
+    void namespaceUriAdapted( String aUri, String aNewUri )
+    {
+        String aMsg = (aUri.equals(BASE_OFFICE_NAMESPACE_URI) || aUri.equals(BASE_DB_NAMESPACE_URI))
+                ? "Adapting Base namspace'" + aUri + "'"
+                : "Adapting OpenDocument CD2 namspace'" + aUri + "' (has been stored by old OOo versions)";
+        m_aLogger.logInfo( aMsg , false);
+    }
+
+    @Override
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAtts) throws SAXException {
+        if( aUri.equals(DRAW_NAMESPACE_URI) && 
+            (aLocalName.equals(POLYGON) || aLocalName.equals(POLYLINE) || aLocalName.equals(CONTOUR_POLYGON)) )
+        {
+            String aPointsValue = aAtts.getValue(DRAW_NAMESPACE_URI,POINTS);
+            if( aPointsValue != null && aPointsValue.length() > MAX_POINTS_LEN )
+            {
+                m_aLogger.logInfo( String.format("'draw:points' of <%s> has been stripped (value starts with '%s')",aQName,aPointsValue.substring(0,40)), false);
+                AttributesImpl aNewAtts = new AttributesImpl( aAtts );
+                int nAttr = aNewAtts.getIndex(DRAW_NAMESPACE_URI,POINTS);
+                int nPos = aPointsValue.lastIndexOf(' ',MAX_POINTS_LEN);
+                String aNewValue = nPos != -1 ? aPointsValue.substring(0,nPos) : "";
+                aNewAtts.setValue(nAttr, aNewValue );
+                aAtts = aNewAtts;
+            }
+        }
+        super.startElement(aUri, aLocalName, aQName, aAtts);
+        if( m_bRoot )
+        {
+            if( !(aUri.equals(OFFICE_NAMESPACE_URI) && aLocalName.equals(m_aLocalElementName)) )
+                m_aLogger.logError("Invalid root element: " + aQName );
+            m_bRoot = false;
+        }
+    }
+
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/DSigFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/DSigFilter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/DSigFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/DSigFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,53 @@
+/************************************************************************
+ *
+ * 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;
+
+class DSigFilter extends NamespaceFilter {
+
+    private static final String OOO_DSIG_NAMESPACE_URI = "http://openoffice.org/2004/documentsignatures";
+    private static final String DSIG_NAMESPACE_URI = "urn:oasis:names:tc:opendocument:xmlns:digitalsignature:1.0";
+        
+    private Logger m_aLogger;
+    
+    /** Creates a new instance of KnownIssueFilter */
+    DSigFilter( Logger aLogger ) {
+        m_aLogger = aLogger;
+    }
+
+    String adaptNamespaceUri( String aUri, String aPrefix)
+    {
+        String aNewUri = null;
+        if( aUri.equals(OOO_DSIG_NAMESPACE_URI) )
+            aNewUri = DSIG_NAMESPACE_URI;
+        
+        return aNewUri;
+    }
+
+    void namespaceUriAdapted( String aUri, String aNewUri )
+    {
+        String aMsg = "Adapting dsig namspace'" + aUri + "'";
+        m_aLogger.logInfo( aMsg , false);
+    }
+
+
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/InternalResources.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/InternalResources.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/InternalResources.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/InternalResources.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,43 @@
+/************************************************************************
+ *
+ * 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 class InternalResources {
+
+    static final private String INTERNAL_RESOURCE_PREFIX = "internal:";
+
+    static boolean isInternalResourceIdentifer( String aPath )
+    {
+        return aPath.startsWith(INTERNAL_RESOURCE_PREFIX);
+    }
+    
+    static String getResourcePath( String aPath )
+    {
+        return "/".concat(aPath.substring(INTERNAL_RESOURCE_PREFIX.length()));
+    }
+    
+    static String createInternalResourceIdentifier( String aPath )
+    {
+        return INTERNAL_RESOURCE_PREFIX.concat(aPath);
+    }
+}

Added: 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=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Logger.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,130 @@
+/************************************************************************
+ *
+ * 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.io.PrintStream;
+
+import org.xml.sax.SAXParseException;
+
+class Logger {
+    
+    static final int INFO = 2;
+    static final int WARNING = 1;
+    static final int ERROR = 0;
+    
+    private String m_aFileName;
+    private String m_aEntryName;
+    private PrintStream m_aOut;
+    private boolean m_bError;
+    private int m_nLevel;
+    
+    private static final String INFO_PREFIX = "Info:";
+    private static final String WARNING_PREFIX = "Warning:";
+    private static final String ERROR_PREFIX = "Error:";
+    private static final String FATAL_PREFIX = "Fatal:";
+    
+    /** Creates a new instance of SchemaErrorHandler */
+    Logger( String aFileName, String aEntryName, PrintStream aOut , int nLevel) {
+        m_aFileName = aFileName;
+        m_aEntryName = aEntryName;
+        m_aOut = aOut;
+        m_nLevel = nLevel;
+        m_bError = false;
+    }
+
+    public void setOutputStream(PrintStream aOut) {
+        m_aOut = aOut;
+    }
+
+    boolean hasError()
+    {
+        return m_bError;
+    }
+
+    void logWarning(String aMsg) {
+        if( m_nLevel >= WARNING )
+            logMessage( WARNING_PREFIX, aMsg );
+    }
+
+    void logFatalError(String aMsg) {
+        logMessage( FATAL_PREFIX, aMsg );
+        m_bError = true;
+    }
+
+    void logError(String aMsg) {
+        if( m_nLevel >= ERROR )
+            logMessage( ERROR_PREFIX, aMsg );
+        m_bError = true;
+    }
+
+    void logInfo(String aMsg, boolean bForceOutput) {
+        if( m_nLevel >= INFO || bForceOutput )
+            logMessage( INFO_PREFIX, aMsg );
+    }
+    
+    void logWarning(SAXParseException e) {
+        if( m_nLevel >= WARNING )
+            logMessage( WARNING_PREFIX, e );
+    }
+
+    void logFatalError(SAXParseException e) {
+        logMessage( FATAL_PREFIX, e );
+        m_bError = true;
+    }
+
+    void logError(SAXParseException e) {
+        if( m_nLevel >= ERROR )
+            logMessage( ERROR_PREFIX, e );
+        m_bError = true;
+    }
+        
+    private void printFileEntryPrefix()
+    {
+        m_aOut.print( m_aFileName );
+        if( m_aEntryName != null && m_aEntryName.length() > 0 )
+        {
+            m_aOut.print( "/" );
+            m_aOut.print( m_aEntryName );
+        }
+    }
+
+    private void logMessage( String aPrefix, SAXParseException e )
+    {
+        printFileEntryPrefix();
+        m_aOut.print( "[" );
+        m_aOut.print( e.getLineNumber() );
+        m_aOut.print( "," );
+        m_aOut.print( e.getColumnNumber() );
+        m_aOut.print( "]:" );
+        m_aOut.print( aPrefix );
+        m_aOut.println( e.getMessage() );
+    }
+    
+    private void logMessage( String aPrefix, String aMsg )
+    {
+        printFileEntryPrefix();
+        m_aOut.print( ":" );
+        m_aOut.print( aPrefix );
+        m_aOut.println( aMsg);
+    }
+}

Added: 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=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/Main.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,289 @@
+/************************************************************************
+ *
+ * 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.io.File;
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.util.Arrays;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Vector;
+
+/**
+ * This application validates an OpenDocument file. To run this application from the command line without Ant, try:
+ * java -jar "[path/]ODFValidator.jar".
+ * @author michael
+ */
+public class Main {
+
+    private static final String VERSION="1.1.2";
+    
+    /** Creates a new instance of Main */
+    public Main() {
+    }
+    
+    /**
+     * @param aArgs the command line arguments
+     */
+    public static void main(String[] aArgs) {
+        
+        String aConfigFileName = null;
+        String aFilterFileName = null;
+        String aSchemaFileName = null;
+        String aOutputFileName = null;
+        String aExcludeRegExp = null;
+        boolean bPrintGenerator = false;
+        boolean bUseMathDTD = false;
+        boolean bPrintHelp = false;
+        boolean bPrintVersion = false;
+        boolean bRecursive = false;
+        int nLogLevel = Logger.ERROR;
+        int nMode = ODFPackageValidator.VALIDATE;
+        List<String> aFileNames = new Vector<String>();
+        String aVersion = null;
+
+        boolean bCommandLineValid = true;
+        List<String> aArgList = Arrays.asList(aArgs);
+        Iterator<String> aArgIter = aArgList.iterator();
+        while( aArgIter.hasNext() && bCommandLineValid )
+        {
+            String aArg = aArgIter.next();
+            if( aArg.equals("-c") )
+            {
+                nMode = ODFPackageValidator.CHECK_CONFORMANCE;
+            }
+            else if( aArg.equals("-d") )
+            {
+                bUseMathDTD = true;
+            }
+            else if( aArg.equals("-e") )
+            {
+                nMode = ODFPackageValidator.CHECK_EXTENDED_CONFORMANCE;
+            }
+            else if( aArg.equals("-f") )
+            {
+                if( aArgIter.hasNext() )
+                    aFilterFileName = aArgIter.next();
+                else
+                    bCommandLineValid = false;
+            }
+            else if( aArg.equals("-g") )
+            {
+                bPrintGenerator = true;
+            }
+            else if( aArg.equals("-h") )
+            {
+                bPrintHelp = true;
+            }
+            else if( aArg.equals("-o") )
+            {
+                if( aArgIter.hasNext() )
+                    aOutputFileName = aArgIter.next();
+                else
+                    bCommandLineValid = false;
+            }
+            else if( aArg.equals("-r") )
+            {
+                bRecursive = true;
+            }
+            else if( aArg.equals("-s") )
+            {
+                nMode = ODFPackageValidator.VALIDATE_STRICT;
+            }
+            else if( aArg.equals("-v") )
+            {
+                nLogLevel = Logger.INFO;
+            }
+            else if( aArg.equals("-w") )
+            {
+                nLogLevel = Logger.WARNING;
+            }
+            else if( aArg.equals("-x") )
+            {
+                if( aArgIter.hasNext() )
+                    aExcludeRegExp = aArgIter.next();
+                else
+                    bCommandLineValid = false;
+            }
+            else if( aArg.equals("-C") )
+            {
+                if( aArgIter.hasNext() )
+                    aConfigFileName = aArgIter.next();
+                else
+                    bCommandLineValid = false;
+            }
+            else if( aArg.equals("-S") )
+            {
+                if( aArgIter.hasNext() )
+                    aSchemaFileName = aArgIter.next();
+                else
+                    bCommandLineValid = false;
+            }
+            else if( aArg.equals("-V") )
+            {
+                bPrintVersion = true;
+            }
+            else if( aArg.equals("-1.0") || aArg.equals("-1.1") || aArg.equals("-1.2") )
+            {
+                aVersion = aArg.substring(1);
+            }
+            else if( aArg.startsWith("-") )
+            {
+                System.out.print(aArg);
+                System.out.println(": unknown option, use '-' for help");
+                return;
+            }
+            else if( aArg.length()>0 )
+            {
+                aFileNames.add( aArg );
+            }
+        }
+
+        // check usage
+        if( bPrintHelp || bPrintVersion )
+        {
+            bCommandLineValid = true;
+        }
+        else if( bPrintGenerator )
+        {
+            bCommandLineValid = aFileNames.size() > 0;
+        }
+        else if( aConfigFileName != null )
+        {
+            bCommandLineValid = aConfigFileName.length() > 0;
+        }
+        else
+        {
+            bCommandLineValid = aFileNames.size() > 0;
+        }
+
+        // print help
+        if( !bCommandLineValid || bPrintHelp )
+        {
+            printUsage();
+            return;
+        }
+        if( bPrintVersion )
+        {
+            System.out.print("odfvalidator v");
+            System.out.println( VERSION );
+            return;
+        }
+        
+        try
+        {
+            // Print generator (does not require config file)
+            if( bPrintGenerator ) 
+            {
+                MetaInformation aMetaInformation = new MetaInformation( System.out );
+                Iterator<String> aIter = aFileNames.iterator();
+                while( aIter.hasNext() )
+                    aMetaInformation.getInformation(aIter.next());
+                return;
+            }
+            
+            // Read configuration
+            Configuration aConfig = null;
+            if( aConfigFileName != null )
+            {
+                File aConfigFile = new File( aConfigFileName );
+                try
+                {
+                    aConfig = new Configuration( aConfigFile );
+                }
+                catch( FileNotFoundException e )
+                {
+                    if( aConfigFileName != null )
+                    {
+                        System.out.println( aConfigFile.getAbsolutePath() + ": file not found.");
+                        return;
+                    }
+                }
+                catch( IOException e )
+                {
+                    System.out.println("error reading " + aConfigFile.getAbsolutePath() + ": " + e.getLocalizedMessage() );
+                    return;
+                }
+            }
+            
+            if( aSchemaFileName != null )
+            {
+                aConfig = new Configuration();
+                aConfig.setProperty( Configuration.STRICT_SCHEMA, aSchemaFileName );
+            }
+
+            PrintStream aOut = aOutputFileName != null ? new PrintStream( aOutputFileName ) : System.out;
+            ODFValidator aValidator = new ODFValidator( aConfig, nLogLevel, aVersion, bUseMathDTD );
+
+            if( aConfigFileName != null )
+            {
+                aValidator.validate(aOut, aConfig, nMode );
+            }
+            else
+            {
+                aValidator.validate(aOut, aFileNames, aExcludeRegExp, nMode, bRecursive, aFilterFileName );
+            }
+        }
+        catch( ODFValidatorException e )
+        {
+            System.out.println( e.getMessage() );
+            System.out.println( "Validation aborted." );
+        }
+        catch( FileNotFoundException e )
+        {
+            System.out.println( e.getMessage() );
+            System.out.println( "Validation aborted." );
+        }
+    }
+    
+    private static void printUsage()
+    {
+        System.out.println( "usage: odfvalidator -g <odffiles>");
+        System.out.println( "       odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-f <filterfile>] [-x <regexp>] [-o outputfile] [-1.0|-1.1|-1.2] <odffiles>");
+        System.out.println( "       odfvalidator [-r] [-c|-e|-s] [-d] [-v|-w] [-f <filterfile>] [-x <regexp>] [-o outputfile] -S <schemafile> <odffiles>");
+        System.out.println( "       odfvalidator [-c|-s] [-v|-w] [-d] [-o outputfile] -C <configfile>");
+        System.out.println( "       odfvalidator -h");
+        System.out.println( "       odfvalidator -V");
+        System.out.println();
+        System.out.println( "-C: Validate using configuration file <configfile>" );
+        System.out.println( "-S: Use schema <schemafile> for validation" );
+        System.out.println( "-V: Print version" );
+        System.out.println( "-c: Check conformance (default for ODF 1.2 documents)" );
+        System.out.println( "-c: Check extended conformance (ODF 1.2 documents only)" );
+        System.out.println( "-d: Use MathML DTD rather than MathML2 schema for validation" );
+        System.out.println( "-f: Use filterfile <filterfile>" );
+        System.out.println( "-g: Show <odffiles> generators and exit" );
+        System.out.println( "-h: Print this help and exit" );
+        System.out.println( "-o: Store validation errors in <outputfile>" );
+        System.out.println( "-r: Process directory recursivly" );
+        System.out.println( "-s: Validate against strict schema (ODF 1.2 documents only)" );
+        System.out.println( "-v: Verbose output, including generator and warnings" );
+        System.out.println( "-w: Print warnings" );
+        System.out.println( "-x: Exclude paths that match <regexp>" );
+        System.out.println();
+        System.out.println( "If no option is provided, <odffiles> are validated using <schemafile>" );
+    }
+
+}

Added: 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=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestEntry.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,35 @@
+/************************************************************************
+ *
+ * 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;
+
+class ManifestEntry
+{
+    String m_aFullPath;
+    String m_aMediaType;
+    
+    ManifestEntry(String aFullPath, String aMediaType)
+    {
+        m_aFullPath = aFullPath;
+        m_aMediaType = aMediaType;
+    }
+}
\ No newline at end of file

Added: 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=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ManifestFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,128 @@
+/************************************************************************
+ *
+ * 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.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;
+
+
+class ManifestFilter extends NamespaceFilter {
+    
+    private static final String OOO_MANIFEST_PUBLIC_ID = "-//OpenOffice.org//DTD Manifest 1.0//EN";
+    private static final String OOO_MANIFEST_NAMESPACE_URI = "http://openoffice.org/2001/manifest";
+    private static final String MANIFEST_NAMESPACE_URI = "urn:oasis:names:tc:opendocument:xmlns:manifest:1.0";
+    
+    private static final String FILE_ENTRY = "file-entry";
+    private static final String FULL_PATH = "full-path";
+    private static final String MEDIA_TYPE = "media-type";
+    
+    private Logger m_aLogger;
+    
+    private String m_aMediaType = "";
+    private Vector<ManifestEntry> m_aSubDocs = new Vector<ManifestEntry>();
+    
+    /** Creates a new instance of KnownIssueFilter */
+    ManifestFilter( Logger aLogger ) {
+        m_aLogger = aLogger;
+    }
+
+    @Override
+    public InputSource resolveEntity(String aPublicId, String aSystemId) throws SAXException, IOException {
+        // Ignore the external OOo Manifest DTD which was errornously included
+        // in early OpenDocument files.
+        
+        if( aPublicId.equals(OOO_MANIFEST_PUBLIC_ID) )
+        {
+            String aMsg = "Ignoring doctype definition '" + OOO_MANIFEST_PUBLIC_ID + "' (has been stored by old OOo versions)";
+            m_aLogger.logInfo( aMsg , false);
+            return new InputSource(new StringReader(""));
+        }
+        else
+            return super.resolveEntity( aPublicId, aSystemId );
+    }
+
+    String adaptNamespaceUri( String aUri, String aPrefix)
+    {
+        String aNewUri = null;
+        if( aUri.equals(OOO_MANIFEST_NAMESPACE_URI) )
+            aNewUri = MANIFEST_NAMESPACE_URI;
+        
+        return aNewUri;
+    }
+
+    void namespaceUriAdapted( String aUri, String aNewUri )
+    {
+        String aMsg = "Adapting OpenOffice.org namspace'" + aUri + "' (has been stored by old OOo versions)";
+        m_aLogger.logInfo( aMsg , false);
+    }
+
+    @Override
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAtts) throws SAXException {
+        super.startElement(aUri, aLocalName, aQName, aAtts);
+        if( (aUri.equals(MANIFEST_NAMESPACE_URI) || aUri.equals(OOO_MANIFEST_NAMESPACE_URI)) && aLocalName.equals(FILE_ENTRY))
+        {
+            String aMediaType = aAtts.getValue(aUri,MEDIA_TYPE);
+            if( aMediaType != null && isOpenDocumentMediaType(aMediaType))
+            {
+                String aFullPath = aAtts.getValue(aUri,FULL_PATH);
+                if( aFullPath != null )
+                {
+                    if( aFullPath.equals("/") )
+                        m_aMediaType = aMediaType;
+                    else
+                        m_aSubDocs.add( 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/MathML101Filter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML101Filter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML101Filter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML101Filter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,98 @@
+/************************************************************************
+ *
+ * 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.io.IOException;
+import java.io.InputStream;
+import org.xml.sax.Attributes;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ *
+ */
+class MathML101Filter extends XMLFilterImpl {
+//class MathML101Filter implements EntityResolver {
+    
+    private String m_aMathMLDTD;
+    private static final String MATHML_NAMESPACE_URI = "http://www.w3.org/1998/Math/MathML";
+    private static final String MATHML_PUBLIC_ID = "-//W3C//DTD MathML 1.01//EN";
+    private static final String OOO_MATHML_PUBLIC_ID = "-//OpenOffice.org//DTD Modified W3C MathML 1.01//EN";
+
+    private Logger m_aLogger;
+    
+    /** Creates a new instance of MathML101Filter */
+    MathML101Filter( String aMathMLDTD,  Logger aLogger )  {
+        m_aMathMLDTD = aMathMLDTD;
+        m_aLogger = aLogger;
+    }
+
+
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAtts) throws SAXException {
+        super.startElement(aUri, aLocalName, aQName, aAtts);
+    }
+
+    public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
+        super.endElement(aUri, aLocalName, aQName);
+    }
+
+    public InputSource resolveEntity(String aPublicId, String aSystemId) throws SAXException, IOException {
+        InputSource aRet = null;
+        String aEntity = null;
+        
+        if( aPublicId != null &&
+            (aPublicId.equals(MATHML_PUBLIC_ID) ||
+            aPublicId.equals(OOO_MATHML_PUBLIC_ID)) )
+        {
+            aEntity = m_aMathMLDTD;
+            if( InternalResources.isInternalResourceIdentifer(aEntity) )
+            {
+                String aPath = InternalResources.getResourcePath(aEntity);
+                InputStream aInStream = getClass().getResourceAsStream(aPath);
+                if( aInStream == null )
+                {
+                    m_aLogger.logFatalError("Missing internal schema file: ".concat(aPath));
+                }
+                else
+                {
+                    aRet = new InputSource( aInStream );
+                    aRet.setPublicId(aPublicId);
+                    aRet.setSystemId(aEntity);
+                }
+            }
+        }
+        else
+        {
+            aEntity = aSystemId;
+        }
+
+        String aMsg = "Reading doctype definition '" + aEntity + "'";
+        m_aLogger.logInfo( aMsg , false);
+
+        if( aRet == null )
+            aRet = new InputSource( aEntity  );
+        return aRet;
+    }
+    
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML20Filter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML20Filter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML20Filter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MathML20Filter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,52 @@
+/************************************************************************
+ *
+ * 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.io.IOException;
+import java.io.StringReader;
+import org.xml.sax.InputSource;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+/**
+ *
+ */
+class MathML20Filter extends XMLFilterImpl {
+    
+    private Logger m_aLogger;
+    
+    /** Creates a new instance of MathMLFilter */
+    MathML20Filter( Logger aLogger) {
+        m_aLogger = aLogger;
+    }
+
+    @Override
+    public InputSource resolveEntity(String aPublicId, String aSystemId) throws SAXException, IOException {
+        // Ignore the external OOo MathML DTD
+        
+        String aMsg = "Ignoring doctype definition '" + aPublicId + "'";
+            m_aLogger.logInfo( aMsg , false);
+        return new InputSource(new StringReader(""));
+    }
+    
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaFilter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,90 @@
+/************************************************************************
+ *
+ * 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.odftoolkit.odfdom.dom.OdfNamespace;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+class MetaFilter extends XMLFilterImpl {
+
+    private boolean m_bInGenerator = false;
+    private String m_aGenerator = "";
+    private boolean m_bRoot = true;
+    
+    private static final String META_NAMESPACE_URI = OdfNamespace.META.toString();
+    private static final String OFFICE_NAMESPACE_URI = OdfNamespace.OFFICE.toString();
+    private static final String GENERATOR = "generator";
+    private static final String DOCUMENT_META = "document-meta";
+
+    private Logger m_aLogger;
+    private MetaInformationListener m_aMetaListener;
+    
+    
+    /** Creates a new instance of MetaFilter */
+    MetaFilter( Logger aLogger, MetaInformationListener aMetaListener ) {
+        m_aLogger = aLogger;
+        m_aMetaListener = aMetaListener;
+    }
+    
+    @Override
+    public void characters(char[] aChars, int nStart, int nLength) throws SAXException {
+        super.characters(aChars, nStart, nLength);
+        
+        if( m_bInGenerator )
+        {
+            m_aGenerator += new String( aChars, nStart, nLength );
+        }
+    }
+
+    @Override
+    public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
+        super.endElement(aUri, aLocalName, aQName);
+        
+        if( aUri.equals(META_NAMESPACE_URI) && aLocalName.equals(GENERATOR) )
+        {
+            m_aGenerator = m_aGenerator.trim();
+            m_aLogger.logInfo( "Generator: " + m_aGenerator , false);
+            m_bInGenerator = false;
+            if( m_aMetaListener!=null ) {
+                m_aMetaListener.setGenerator( m_aGenerator );
+            }
+        }
+    }
+
+    @Override
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAttributes) throws SAXException {
+        super.startElement(aUri, aLocalName, aQName, aAttributes);
+
+        if( m_bRoot )
+        {
+            if( !(aUri.equals(OFFICE_NAMESPACE_URI) && aLocalName.equals(DOCUMENT_META)) )
+                m_aLogger.logError("Invalid root element: " + aQName );
+            m_bRoot = false;
+        }
+                
+        if( aUri.equals(META_NAMESPACE_URI) && aLocalName.equals(GENERATOR) )
+            m_bInGenerator = true;
+    }
+}

Added: 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=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformation.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,99 @@
+/************************************************************************
+ *
+ * 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.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.InputSource;
+import org.xml.sax.XMLFilter;
+import org.odftoolkit.odfdom.pkg.OdfPackage;
+
+public class MetaInformation {
+
+    private PrintStream m_aOut;
+    
+    /** Creates a new instance of Validator */
+    public MetaInformation( PrintStream aOut ) {
+        
+        m_aOut = aOut;
+    }
+
+    public void getInformation( String aDocFileName ) throws ODFValidatorException
+    {
+        try
+        {
+            OdfPackage aDocFile = OdfPackage.loadPackage( aDocFileName );
+            
+            getGenerator( aDocFile );
+        }
+        catch( Exception e )
+        {
+            throw new ODFValidatorException( aDocFileName, "", e );
+        }  
+    }
+    
+    public void getGenerator( OdfPackage aDocFile ) throws ODFValidatorException
+    {
+        try
+        {
+            InputStream aInStream = aDocFile.getInputStream(OdfPackage.OdfFile.MANIFEST.getPath());
+            Logger aLogger = new Logger(aDocFile.getBaseURI(),OdfPackage.OdfFile.MANIFEST.getPath(),m_aOut, Logger.INFO);
+        
+            getInformation( aInStream, aLogger );
+        }
+        catch( Exception e )
+        {
+            throw new ODFValidatorException( aDocFile.getBaseURI(), "", e );
+        }  
+    }
+
+
+    
+    private void getInformation( InputStream aInStream, Logger aLogger ) throws IOException, ODFValidatorException
+    {
+        SAXParser aParser = null;
+        try
+        {
+            SAXParserFactory aParserFactory = SAXParserFactory.newInstance();
+            aParserFactory.setNamespaceAware(true);
+            aParser = aParserFactory.newSAXParser();
+
+            XMLFilter aFilter =  new MetaFilter(aLogger,null);
+            aFilter.setParent( aParser.getXMLReader() ) ;
+
+            aFilter.parse(new InputSource(aInStream));
+        }
+        catch( javax.xml.parsers.ParserConfigurationException e )
+        {
+            throw new ODFValidatorException( e );
+        }
+        catch( org.xml.sax.SAXException e )
+        {
+            throw new ODFValidatorException( e );
+        }
+    }
+
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformationListener.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformationListener.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformationListener.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/MetaInformationListener.java Mon Sep 19 05:32:56 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 MetaInformationListener {
+    
+    void setGenerator( String aGenerator );
+    
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/NamespaceFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/NamespaceFilter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/NamespaceFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/NamespaceFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,94 @@
+/************************************************************************
+ *
+ * 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;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.AttributesImpl;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+abstract class NamespaceFilter extends XMLFilterImpl {
+    
+    private boolean m_bFilterNamespaceUri = false;
+
+    /** Creates a new instance of NamespaceFilter */
+    NamespaceFilter() {
+    }
+
+    abstract String adaptNamespaceUri(String aUri, String aPrefix);
+    abstract void namespaceUriAdapted(String aUri, String aNewUri);
+
+
+    public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
+        if (m_bFilterNamespaceUri)
+        {    
+            String aNewUri = adaptNamespaceUri( aUri , aQName );
+            
+            if( aNewUri != null )
+                aUri = aNewUri;
+        }
+        
+        super.endElement(aUri, aLocalName, aQName);
+    }
+
+
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAtts) throws SAXException {
+        if (m_bFilterNamespaceUri)
+        {    
+            String aNewUri = adaptNamespaceUri( aUri , aQName);
+            
+            if( aNewUri != null )
+                aUri = aNewUri;
+
+            Attributes aOldAtts = aAtts;
+            AttributesImpl aNewAtts = null;
+            for (int i = 0; i < aOldAtts.getLength(); ++i)
+            {
+                aNewUri = adaptNamespaceUri( aOldAtts.getURI(i) , aQName);
+                if (aNewUri != null)
+                {
+                    if (aNewAtts == null)
+                    {
+                        aNewAtts = new AttributesImpl(aOldAtts);
+                        aAtts = aNewAtts;
+                    }
+                    aNewAtts.setURI(i,aNewUri);
+                }
+            }
+        }
+        super.startElement(aUri, aLocalName, aQName, aAtts);
+    }
+
+
+
+    public void startPrefixMapping(String aPrefix, String aUri) throws SAXException {
+        String aNewUri = adaptNamespaceUri( aUri, aPrefix);
+        if (aNewUri != null)
+        {
+            m_bFilterNamespaceUri = true;
+            namespaceUriAdapted( aUri, aNewUri );
+        }
+        super.startPrefixMapping(aPrefix, aUri);
+    }
+    
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileFilter.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileFilter.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileFilter.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,87 @@
+/************************************************************************
+ *
+ * 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.io.File;
+import java.io.FileFilter;
+import java.util.regex.Pattern;
+
+        
+public class ODFFileFilter implements FileFilter
+{
+    private boolean m_bRecursive;
+    private Pattern m_aExcludePattern = null;
+    
+    public ODFFileFilter( boolean bRecursive )
+    {
+        m_bRecursive = bRecursive;
+    }
+
+    public ODFFileFilter( String aExcludeRegExp, boolean bRecursive )
+    {
+        m_bRecursive = bRecursive;
+        if( aExcludeRegExp != null )
+            m_aExcludePattern = Pattern.compile(aExcludeRegExp);
+    }
+    
+    
+    public boolean accept(File aFile) {
+        return !exclude( aFile ) && (aFile.isDirectory() ? m_bRecursive : hasODFExtension( aFile ));
+    }
+    
+    private boolean exclude(File aFile)
+    {
+        boolean bExclude = false;
+        if( m_aExcludePattern != null )
+            bExclude = m_aExcludePattern.matcher(aFile.getAbsolutePath()).matches();
+        return bExclude;
+    }
+    
+    private boolean hasODFExtension(File aFile)
+    {
+        String aName = aFile.getName();
+        int nIndex = aName.lastIndexOf('.');
+        if (nIndex != -1 && aName.length() > nIndex+1)
+        {
+            String aExt = aName.substring(nIndex+1);
+            if( aExt.length() == 3 )
+            {
+                return aExt.equalsIgnoreCase("odt") ||
+                       aExt.equalsIgnoreCase("ods") ||
+                       aExt.equalsIgnoreCase("odg") ||
+                       aExt.equalsIgnoreCase("odp") ||
+                       aExt.equalsIgnoreCase("odf") ||
+                       aExt.equalsIgnoreCase("odc") ||
+                       aExt.equalsIgnoreCase("odb") ||
+                       aExt.equalsIgnoreCase("ott") ||
+                       aExt.equalsIgnoreCase("ots") ||
+                       aExt.equalsIgnoreCase("otg") ||
+                       aExt.equalsIgnoreCase("otp") ||
+                       aExt.equalsIgnoreCase("otf") ||
+                       aExt.equalsIgnoreCase("otc");
+            }
+        }
+        
+        return false;
+    }
+}

Added: 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=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFFileValidator.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,55 @@
+/************************************************************************
+ *
+ * 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.io.File;
+import org.odftoolkit.odfdom.pkg.OdfPackage;
+
+/**
+ * Validator for Files
+ */
+public class ODFFileValidator extends ODFRootPackageValidator {
+    
+    private File m_aFile = null;
+
+        /** Creates a new instance of ODFFileValidator */
+    public ODFFileValidator( File aFile, int nLogLevel, 
+                             int nMode, String aVersion,
+                             SAXParseExceptionFilter aFilter,
+                             ODFValidatorProvider aValidatorProvider ) throws ODFValidatorException
+    {
+        super( nLogLevel, nMode, aVersion, aFilter, aValidatorProvider );
+        m_aFile = aFile;
+    }
+
+    protected String getLoggerName()
+    {
+        return m_aFile.getAbsolutePath();
+    }
+
+    protected OdfPackage getPackage() throws Exception
+    {
+        return OdfPackage.loadPackage( m_aFile );
+    }
+
+}

Added: incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFMediaTypes.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFMediaTypes.java?rev=1172437&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFMediaTypes.java (added)
+++ incubator/odf/trunk/validator/src/org/odftoolkit/odfvalidator/ODFMediaTypes.java Mon Sep 19 05:32:56 2011
@@ -0,0 +1,50 @@
+/************************************************************************
+ *
+ * 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;
+
+/**
+ * abstract Base class for OpenDocument filetype classes
+ */
+public abstract class ODFMediaTypes {
+
+    public static final String TEXT_MEDIA_TYPE = "application/vnd.oasis.opendocument.text";
+    public static final String TEXT_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.text-template";
+    public static final String GRAPHICS_MEDIA_TYPE = "application/vnd.oasis.opendocument.graphics";
+    public static final String GRAPHICS_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.graphics-template";
+    public static final String PRESENTATION_MEDIA_TYPE = "application/vnd.oasis.opendocument.presentation";
+    public static final String PRESENTATION_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.presentation-template";
+    public static final String SPREADSHEET_MEDIA_TYPE = "application/vnd.oasis.opendocument.spreadsheet";
+    public static final String SPREADSHEET_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.spreadsheet-template";
+    public static final String CHART_MEDIA_TYPE = "application/vnd.oasis.opendocument.chart";
+    public static final String CHART_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.chart-template";
+    public static final String IMAGE_MEDIA_TYPE = "application/vnd.oasis.opendocument.image";
+    public static final String IMAGE_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.image-template";
+    public static final String FORMULA_MEDIA_TYPE = "application/vnd.oasis.opendocument.formula";
+    public static final String FORMULA_TEMPLATE_MEDIA_TYPE = "application/vnd.oasis.opendocument.formula-template";
+    public static final String TEXT_MASTER_MEDIA_TYPE = "application/vnd.oasis.opendocument.text-master";
+    public static final String TEXT_WEB_MEDIA_TYPE = "application/vnd.oasis.opendocument.text-web";
+
+   
+}
+
+



Mime
View raw message