incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1172430 [3/3] - in /incubator/odf/trunk/validator: ./ misc/ nbproject/ src/ src/odfvalidator/ xslt/
Date Mon, 19 Sep 2011 05:30:40 GMT
Added: incubator/odf/trunk/validator/src/odfvalidator/ODFValidator.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/ODFValidator.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/ODFValidator.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/ODFValidator.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,388 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import javax.xml.XMLConstants;
+
+import javax.xml.validation.Schema;
+import javax.xml.validation.SchemaFactory;
+
+import java.io.File;
+import java.io.FileFilter;
+import java.io.IOException;
+import java.io.PrintStream;
+import java.io.InputStream;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import javax.xml.transform.stream.StreamSource;
+import javax.xml.validation.Validator;
+
+public class ODFValidator implements ODFValidatorProvider {
+
+    // Prefix used to distinguish internal resources from external ones
+    
+    // Loglevel
+    private int m_nLogLevel;
+
+    // Validator provider
+    private SchemaFactory m_aRNGSchemaFactory = null;
+    private SchemaFactory m_aXSDSchemaFactory = null;
+
+    // User provided Configuration
+    protected Configuration m_aConfig = null;
+    
+    // User provided ODF version
+    protected String 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;
+
+    // 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,
+                         boolean bUseMathDTD ) throws ODFValidatorException {
+        
+        m_nLogLevel = nLogLevel;
+        m_aConfig = aConfig;
+        m_aVersion = aVersion;
+        m_bUseMathDTD = bUseMathDTD;
+    }    
+    
+    public boolean validate(PrintStream aOut, Configuration aConfig, int nMode ) throws ODFValidatorException
+    {
+        List<String> aFileNames = aConfig.getListPropety(Configuration.PATH);
+        String aExcludeRegExp = aConfig.getProperty(Configuration.EXCLUDE);
+        String aRecursive = aConfig.getProperty(Configuration.RECURSIVE);
+        boolean bRecursive = aRecursive != null ? Boolean.valueOf(aRecursive) : false;
+        String aFilterFileName = aConfig.getProperty(Configuration.FILTER);
+
+        return validate(aOut, aFileNames, aExcludeRegExp, nMode, bRecursive, aFilterFileName );
+    }
+
+
+    public boolean validate(PrintStream aOut, List<String> aFileNames, String aExcludeRegExp, 
+                            int nMode, boolean bRecursive,                            
+                            String aFilterFileName ) throws ODFValidatorException
+    {
+        boolean bRet = false;
+
+        SAXParseExceptionFilter aFilter = null;
+        if( aFilterFileName != null && aFilterFileName.length() != 0 )
+            aFilter = new ValidationOOoTaskIdErrorFilter( new File(aFilterFileName), aOut );
+
+        FileFilter aFileFilter = new ODFFileFilter( aExcludeRegExp, bRecursive );
+        
+        Iterator<String> aIter = aFileNames.iterator();
+        while( aIter.hasNext() )
+        {
+            File aFile = new File( aIter.next() );
+            bRet |= aFile.isDirectory() ? validateDir(aOut, aFile, aFileFilter, nMode, aFilter )
+                : validateFile(aOut, aFile, nMode, aFilter );
+        }
+        
+        return bRet;
+    }
+    
+    public boolean validate(PrintStream aOut, InputStream aInputStream, String aBaseURI,
+                            int nMode,
+                            SAXParseExceptionFilter aFilter ) throws ODFValidatorException
+    {
+        return validateStream( aOut, aInputStream, aBaseURI, nMode, aFilter );
+    }
+    
+
+    private boolean validateDir(PrintStream aOut, final File aDir, FileFilter aFileFilter, int nMode, SAXParseExceptionFilter aFilter ) throws ODFValidatorException 
+    {
+        boolean bRet = true;
+        File[] aFiles = aDir.listFiles( aFileFilter );
+
+        if( aFiles != null )
+        {
+            for( int i=0; i<aFiles.length; ++i)
+            {
+                File aFile = aFiles[i];
+                if( aFile.isDirectory() )
+                {
+                    bRet |= validateDir(aOut, aFile, aFileFilter, nMode, aFilter );
+                }
+                else
+                {
+                    bRet |= validateFile(aOut, aFile, nMode, aFilter );
+                }
+            }
+        }
+        return bRet;
+    }
+
+    /**
+     * validate the input File
+     *
+     * <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
+    {
+        ODFFileValidator aFileValidator = 
+            new ODFFileValidator( aDocFile, m_nLogLevel, nMode, aFilter, this );
+        
+        boolean result=aFileValidator.validate(aOut);
+
+        m_aGenerator=aFileValidator.getGenerator();
+        return result;
+    }
+
+    /**
+     * validate the input Stream
+     *
+     * <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,
+                                  SAXParseExceptionFilter aFilter ) throws ODFValidatorException
+    {
+        ODFStreamValidator aStreamValidator = 
+            new ODFStreamValidator( aInputStream, aBaseURI, m_nLogLevel, nMode, aFilter, this );
+
+        boolean result=aStreamValidator.validate(aOut);
+        m_aGenerator=aStreamValidator.getGenerator();
+
+        return result;
+    }
+
+    public Validator getManifestValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    {
+        return getValidatorForSchema( aOut, getSchemaFileName(Configuration.MANIFEST_SCHEMA,aVersion));
+    }
+    
+    public Validator getValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    {
+        return getValidatorForSchema( aOut, getSchemaFileName(Configuration.SCHEMA,aVersion));
+    }
+    
+    public Validator getStrictValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    {
+        return getValidatorForSchema( aOut, getSchemaFileName(Configuration.STRICT_SCHEMA,aVersion));
+    }
+    
+    public Validator getMathMLValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    {
+        return getValidatorForSchema( aOut, getSchemaFileName(Configuration.MATHML2_SCHEMA,aVersion));
+    }
+    
+    public String getMathMLDTDSystemId( String aVersion ) throws ODFValidatorException
+    {
+        String aDTD = null;
+        if( m_bUseMathDTD )
+        {
+            Configuration aConfig = 
+                m_aConfig != null ? m_aConfig
+                                  : getConfiguration( m_aVersion != null ? m_aVersion : aVersion );
+
+            aDTD = aConfig.getProperty(Configuration.MATHML_SCHEMA);
+            if( m_aConfig == null && aDTD != null && aDTD.length() > 0  )
+                aDTD = InternalResources.createInternalResourceIdentifier(aDTD);
+        }
+
+        return aDTD;
+    }
+    
+    public Validator getDSigValidator(PrintStream aOut, String aVersion) throws ODFValidatorException
+    {
+        return getValidatorForSchema( aOut, getSchemaFileName(Configuration.DSIG_SCHEMA,aVersion));
+    }
+
+    public void resetValidatorProvider()
+    {
+        m_aRNGSchemaFactory = null;
+        m_aXSDSchemaFactory = null;
+        m_aValidatorMap = null;
+    }
+
+    private String getSchemaFileName( String aConfigName, String aVersion) throws ODFValidatorException
+    {
+        Configuration aConfig = 
+            m_aConfig != null ? m_aConfig
+                              : getConfiguration( m_aVersion != null ? m_aVersion : aVersion );
+
+        String aFileName = aConfig.getProperty(aConfigName);
+        if( m_aConfig == null && aFileName != null && aFileName.length() > 0  )
+            aFileName = InternalResources.createInternalResourceIdentifier(aFileName);
+        
+        return aFileName;
+    }
+
+    private Configuration getConfiguration( String aVersion ) throws ODFValidatorException
+    {
+        if( m_aConfigurationMap == null )
+            m_aConfigurationMap = new HashMap<String,Configuration>();
+        
+        Configuration aConfig = m_aConfigurationMap.get(aVersion);
+        if( aConfig == null)
+        {
+            String aConfigName = null;
+            if( aVersion == null || aVersion.equals("1.2") )
+                aConfigName = "/config/v12.properties";
+            else if( aVersion.equals("1.1") )
+                aConfigName = "/config/v11.properties";
+            else if( aVersion.equals("1.0") )
+                aConfigName = "/config/v10.properties";
+            else
+                throw new ODFValidatorException( "unsupported ODF version: ".concat(aVersion) );
+            
+            InputStream aInStream = getClass().getResourceAsStream(aConfigName);
+            if( aInStream == null )
+                throw new ODFValidatorException( "Internal configuration file is missing: ".concat(aConfigName));
+
+            aConfig = new Configuration();
+            try
+            {
+                aConfig.loadFromXML( aInStream );
+                aInStream.close();
+            }
+            catch( IOException e )
+            {
+                throw new ODFValidatorException( e );
+            }
+            
+            m_aConfigurationMap.put( aVersion, aConfig );
+        }
+
+        return aConfig;
+    }
+    
+    private Validator getValidatorForSchema( PrintStream aOut, String aSchemaFileName ) throws ODFValidatorException
+    {
+        if( m_aValidatorMap == null )
+            m_aValidatorMap = new HashMap<String,Validator>();
+        
+        Validator aValidator = m_aValidatorMap.get(aSchemaFileName);
+        if( aValidator == null )
+        {
+            aValidator = createValidator( aOut, aSchemaFileName );
+            m_aValidatorMap.put( aSchemaFileName, aValidator);
+        }
+        
+        return aValidator;
+    }
+    
+    private Validator createValidator(PrintStream aOut, String aSchemaFileName ) throws ODFValidatorException 
+    {
+        Logger aLogger = new Logger(aSchemaFileName, "", aOut, m_nLogLevel);
+        
+        if( aSchemaFileName == null || aSchemaFileName.length() == 0 )
+            return null;
+        
+        String aSchemaLanguage = 
+                aSchemaFileName.endsWith("xsd") ? XMLConstants.W3C_XML_SCHEMA_NS_URI
+                                                : XMLConstants.RELAXNG_NS_URI;
+        SchemaFactory aSchemaFactory = getSchemaFactory( aSchemaLanguage );
+        SchemaErrorHandler aErrorHandler = new SchemaErrorHandler( aLogger, null );
+        aSchemaFactory.setErrorHandler( aErrorHandler );
+        aSchemaFactory.setResourceResolver(new SchemaResourceResolver(aLogger,aSchemaFileName));
+        Schema aSchema = null;
+
+        StreamSource aSource = null;
+        if( InternalResources.isInternalResourceIdentifer(aSchemaFileName) )
+        {
+            String aPath = InternalResources.getResourcePath(aSchemaFileName);
+            InputStream aInStream = getClass().getResourceAsStream(aPath);
+            if( aInStream == null )
+                throw new ODFValidatorException( "Internal schema file is missing: ".concat(aPath));
+
+            aSource = new StreamSource(aInStream,aSchemaFileName);
+        }
+        else
+        {
+            File aFile=new File(aSchemaFileName);
+            if ( ! aFile.exists() ) {
+                aLogger.logFatalError( aSchemaFileName+": file does not exist" );
+                return null;
+            }
+            aSource = new StreamSource(aFile);
+        }
+
+        boolean bError = false; // Workaround: MSV seems not to call error handler
+        try
+        {
+            aSchema = aSchemaFactory.newSchema( aSource );
+        }
+        catch( org.xml.sax.SAXParseException e )
+        {
+            aLogger.logFatalError( e );
+        }
+        catch( org.xml.sax.SAXException e )
+        {
+            aLogger.logFatalError( e.getMessage() );
+        }
+        
+        if( aLogger.hasError() )
+        {
+            throw new ODFValidatorException( aSchemaFileName, "", "Schema has validation errors.");
+        }
+
+        aLogger.logInfo( "parsed." , false);
+        return aSchema.newValidator();
+    }
+
+    private SchemaFactory getSchemaFactory( String aSchemaLanguage ) throws ODFValidatorException
+    {
+        boolean bRNG = aSchemaLanguage.equals(XMLConstants.RELAXNG_NS_URI);
+        SchemaFactory aSchemaFactory = bRNG ? m_aRNGSchemaFactory
+                                            : m_aXSDSchemaFactory;
+        if( aSchemaFactory == null )
+        {
+
+            try
+            {
+                aSchemaFactory = SchemaFactory.newInstance( aSchemaLanguage );
+            }
+            catch( IllegalArgumentException e ) 
+            {
+                throw new ODFValidatorException( (bRNG ? "Relax-NG" : "W3C XML Schema") + " support is not installed: " + e.getMessage() );
+            }
+            if( bRNG )
+                m_aRNGSchemaFactory = aSchemaFactory;
+            else
+                m_aXSDSchemaFactory = aSchemaFactory;
+        }
+        
+        return aSchemaFactory;
+    }
+
+    /**
+     * get Generator from last validateFile or validateStream call
+     */
+    public String getGenerator() {
+        return m_aGenerator;
+    }
+
+  
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorException.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorException.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorException.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorException.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,70 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+public class ODFValidatorException extends Exception {
+    
+    private String m_aFile;
+    private String m_aEntry;
+    
+    /** Creates a new instance of ODFValidatorException */
+    ODFValidatorException( Exception e) {
+        super( e );
+    }
+    
+    ODFValidatorException( String aMsg ) {
+        super( aMsg );
+    }
+
+    ODFValidatorException( String aFile, String aEntry, String aMsg ) {
+        super( aMsg );
+        m_aFile = aFile;
+        m_aEntry = aEntry;
+    }
+ 
+    ODFValidatorException( String aFile, String aEntry, Exception e ) {
+        super( e );
+        m_aFile = aFile;
+        m_aEntry = aEntry;
+    }
+
+    @Override
+    public String getMessage() {
+        String retValue = "";
+        
+        if( m_aFile != null && m_aFile.length() > 0 )
+        {
+            retValue += m_aFile;
+            retValue += ":";
+        }
+        if( m_aEntry != null && m_aEntry.length() > 0 )
+        {
+            retValue += m_aEntry;
+            retValue += ":";
+        }
+        retValue += super.getMessage();
+        return retValue;
+    }
+    
+    
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorProvider.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorProvider.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorProvider.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/ODFValidatorProvider.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,42 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import javax.xml.validation.Validator;
+import java.io.PrintStream;
+
+public interface ODFValidatorProvider {
+    Validator getValidator(PrintStream aOut, String aVersion ) throws ODFValidatorException;
+
+    Validator getStrictValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+    
+    Validator getManifestValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+
+    Validator getDSigValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+
+    Validator getMathMLValidator(PrintStream aOut, String aVersion) throws ODFValidatorException;
+
+    String getMathMLDTDSystemId( String aVersion ) throws ODFValidatorException;
+        
+    void resetValidatorProvider();
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/OdfPackageExt.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/OdfPackageExt.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/OdfPackageExt.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/OdfPackageExt.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,30 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+public class OdfPackageExt {
+
+    public static final String STREAMNAME_DOCUMENT_SIGNATURES = "META-INF/documentsignatures.xml";    
+    public static final String STREAMNAME_MACRO_SIGNATURES = "META-INF/macrosignatures.xml";    
+
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/SAXParseExceptionFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/SAXParseExceptionFilter.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/SAXParseExceptionFilter.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/SAXParseExceptionFilter.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,36 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import org.xml.sax.SAXParseException;
+
+public interface SAXParseExceptionFilter {
+    
+    SAXParseException filterException( SAXParseException e );
+    
+    void startPackage( String aParentGenerator );
+    
+    void setGenerator( String aGenerator );
+    
+    void startSubFile();
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/SAXVersionException.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/SAXVersionException.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/SAXVersionException.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/SAXVersionException.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,41 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import org.xml.sax.SAXException;
+
+class SAXVersionException extends SAXException{
+
+    private String m_aVersion = null;
+    
+    SAXVersionException( String aVersion )
+    {
+        super();
+        m_aVersion = aVersion;
+    }
+    
+    String getVersion()
+    {
+        return m_aVersion;
+    }
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/SchemaErrorHandler.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/SchemaErrorHandler.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/SchemaErrorHandler.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/SchemaErrorHandler.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,78 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+
+class SchemaErrorHandler implements org.xml.sax.ErrorHandler {
+    
+    private Logger m_aLogger;
+    private SAXParseExceptionFilter m_aFilter;
+
+    /** Creates a new instance of SchemaErrorHandler */
+    SchemaErrorHandler(Logger aLogger, SAXParseExceptionFilter aFilter ) {
+        m_aLogger = aLogger;
+        m_aFilter = aFilter;
+    }
+    
+    public void warning(SAXParseException e) throws SAXException {
+        if( !filter(e) )
+            m_aLogger.logWarning(  e );
+    }
+
+    public void fatalError(SAXParseException e) throws SAXException {
+        fatalErrorNoException( e );
+    }
+
+    public void error(SAXParseException e) throws SAXException {
+        if( !filter(e) )
+            m_aLogger.logError( e );
+    }
+
+    public void fatalErrorNoException(SAXParseException e) {
+        if( !filter(e) )
+            m_aLogger.logFatalError(  e );
+    }
+    
+    private boolean filter( SAXParseException e )
+    {
+        boolean bFiltered = false;
+        if( m_aFilter != null )
+        {
+            SAXParseException aNewExc = m_aFilter.filterException( e );
+            if( aNewExc == null  )
+            {
+                bFiltered = true;
+            }
+            else if( aNewExc != e )
+            {
+                m_aLogger.logWarning( aNewExc );
+                bFiltered = true;
+            }
+        }
+        
+        return bFiltered;
+    }
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/SchemaFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/SchemaFilter.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/SchemaFilter.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/SchemaFilter.java Mon Sep 19 05:30:38 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 odfvalidator;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.XMLFilterImpl;
+
+class SchemaFilter extends XMLFilterImpl {
+    
+    /** Creates a new instance of SchemaFilter */
+    SchemaFilter() {
+    }
+
+    @Override
+    public void startElement(String uri, String localName, String qName, Attributes atts) throws SAXException {
+
+        if( qName.equals("param"))
+        {
+            System.out.println( atts.getValue(uri,"pattern"));
+        }
+        super.startElement(uri, localName, qName, atts);
+    }
+    
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/SchemaResourceResolver.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/SchemaResourceResolver.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/SchemaResourceResolver.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/SchemaResourceResolver.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,194 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import java.io.InputStream;
+import java.io.Reader;
+import org.w3c.dom.DOMImplementation;
+import org.w3c.dom.bootstrap.DOMImplementationRegistry;
+import org.w3c.dom.ls.DOMImplementationLS;
+import org.w3c.dom.ls.LSInput;
+import org.w3c.dom.ls.LSResourceResolver;
+
+    class SchemaResourceResolver implements LSResourceResolver 
+    {
+        private String m_aBaseURI = null;
+        private Logger m_aLogger = null;
+        private DOMImplementationLS m_aDOMImplLS = null;
+        private boolean m_bGetDOMImplLSFailed = false;
+        
+        class LSInputImpl implements LSInput
+        {
+            private InputStream m_aInputStream = null;
+            private String m_aSystemId = null;
+
+            public Reader getCharacterStream() {
+                return null;
+            }
+
+            public void setCharacterStream(Reader aCharacterStream) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            public InputStream getByteStream() {
+                return m_aInputStream;
+            }
+
+            public void setByteStream(InputStream aByteStream) {
+                m_aInputStream = aByteStream;
+            }
+
+            public String getStringData() {
+                return null;
+            }
+
+            public void setStringData(String stringData) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            public String getSystemId() {
+                return m_aSystemId;
+            }
+
+            public void setSystemId(String aSystemId) {
+                m_aSystemId = aSystemId;
+            }
+
+            public String getPublicId() {
+                return null;
+            }
+
+            public void setPublicId(String publicId) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            public String getBaseURI() {
+                return null;
+            }
+
+            public void setBaseURI(String baseURI) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            public String getEncoding() {
+                return null;
+            }
+
+            public void setEncoding(String encoding) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+            public boolean getCertifiedText() {
+                return false;
+            }
+
+            public void setCertifiedText(boolean certifiedText) {
+                throw new UnsupportedOperationException("Not supported yet.");
+            }
+
+        }
+        
+        public SchemaResourceResolver( Logger aLogger, String aBaseURI )
+        {
+            m_aBaseURI = aBaseURI;
+            m_aLogger = aLogger;
+        }
+    
+        public LSInput resolveResource(String aType, String aNamespaceURI, String aPublicId, String aSystemId, String aBaseURI) 
+        {
+            LSInput aInput = null;
+            
+            if( aBaseURI == null )
+                aBaseURI = m_aBaseURI; 
+
+            if( aSystemId != null && aBaseURI != null && 
+                InternalResources.isInternalResourceIdentifer(aBaseURI) )
+            {
+                String aURI = aBaseURI.substring(0, aBaseURI.lastIndexOf('/')+1).concat(aSystemId);
+                String aPath = InternalResources.getResourcePath(aURI);
+                InputStream aInStream = getClass().getResourceAsStream(aPath);
+                if( aInStream != null )
+                {
+                    aInput = createLSInput();
+                    aInput.setSystemId(aURI);
+                    aInput.setByteStream(aInStream);
+ 
+                    String aMsg = "resolving '" + aURI + "'";
+                    m_aLogger.logInfo( aMsg , false);
+                }
+                else
+                {
+                    m_aLogger.logFatalError("Missing internal schema file: ".concat(aPath));
+                }
+            }
+        
+           return aInput;
+        }
+        
+        private LSInput createLSInput()
+        {
+            LSInput aLSInput = null;
+            
+            if( m_aDOMImplLS == null && !m_bGetDOMImplLSFailed )
+            {
+                DOMImplementationRegistry aDOMReg = null;
+
+                try
+                {        
+                    aDOMReg = DOMImplementationRegistry.newInstance();
+                }
+                catch( ClassNotFoundException e )
+                {
+                    m_aLogger.logFatalError(e.getMessage());
+                }
+                catch( InstantiationException e )
+                {
+                    m_aLogger.logFatalError(e.getMessage());
+                }
+                catch( IllegalAccessException e )
+                {
+                    m_aLogger.logFatalError(e.getMessage());
+                }
+                DOMImplementation aDOMImpl = aDOMReg.getDOMImplementation( "LS 3.0");
+                if( aDOMImpl != null )
+                {
+                    m_aDOMImplLS = (DOMImplementationLS)aDOMImpl;
+                }
+                else
+                {
+                    m_bGetDOMImplLSFailed = true;
+                    m_aLogger.logInfo("Could not find DOM LS 3.0 Implementation, using own implementation", false);
+                }
+            }
+            if( m_aDOMImplLS != null )
+            {
+                aLSInput = m_aDOMImplLS.createLSInput();
+            }
+            else
+            {
+                aLSInput = new LSInputImpl();
+            }
+            
+            return aLSInput;
+        }
+    }

Added: incubator/odf/trunk/validator/src/odfvalidator/ValidationMessageCollectorErrorFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/ValidationMessageCollectorErrorFilter.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/ValidationMessageCollectorErrorFilter.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/ValidationMessageCollectorErrorFilter.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,74 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import java.util.HashSet;
+import org.xml.sax.SAXParseException;
+
+/**
+ *
+ */
+public class ValidationMessageCollectorErrorFilter implements SAXParseExceptionFilter {
+
+    private String m_aGenerator;
+    private HashSet<String> m_aMsgsReported;
+
+    
+    /** Creates a new instance of ValidationErrorFilter */
+    public ValidationMessageCollectorErrorFilter() throws ODFValidatorException {
+        m_aMsgsReported = new HashSet<String>();
+    }
+    
+    public SAXParseException filterException( SAXParseException aExc )
+    {
+        String aMsg = aExc.getMessage();
+        if( !m_aMsgsReported.contains(aMsg))
+        {
+             m_aMsgsReported.add( aMsg );
+        }
+        
+        return aExc;
+    }
+
+    public void startPackage( String aGenerator )
+    {
+    }
+
+    public void setGenerator( String aGenerator )
+    {
+        m_aGenerator = aGenerator;
+    }
+    
+    public void startSubFile() {
+    }    
+    
+    public String getGenerator()
+    {
+        return m_aGenerator;
+    }
+
+    public HashSet<String> getMessages()
+    {
+        return m_aMsgsReported;
+    }
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/ValidationOOoTaskIdErrorFilter.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/ValidationOOoTaskIdErrorFilter.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/ValidationOOoTaskIdErrorFilter.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/ValidationOOoTaskIdErrorFilter.java Mon Sep 19 05:30:38 2011
@@ -0,0 +1,210 @@
+/************************************************************************
+ *
+ * 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 odfvalidator;
+
+import java.io.File;
+import java.io.PrintStream;
+import java.util.HashMap;
+import java.util.HashSet;
+import javax.xml.parsers.SAXParser;
+import javax.xml.parsers.SAXParserFactory;
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.SAXParseException;
+import org.xml.sax.helpers.DefaultHandler;
+
+/**
+ *
+ */
+public class ValidationOOoTaskIdErrorFilter implements SAXParseExceptionFilter {
+
+    
+    private static final String FILTER_ENTRY = "filter-entry";
+    private static final String TASK_ID = "task-id";
+    private static final String RESOLVED_IN = "resolved-in";
+    
+    int m_nBuildId = 0;
+    
+    class FilterEntry
+    {
+        String m_aTaskId;
+        int m_nBuildId;
+        
+        FilterEntry( String aTaskId, int nBuildId )
+        {
+            m_aTaskId = aTaskId;
+            m_nBuildId = nBuildId;
+        }
+    }
+            
+
+    private HashMap<String,FilterEntry> m_aFilterEntries;
+    private HashSet<String> m_aTaskIdsReported;
+
+    class Handler extends DefaultHandler
+    {
+        class Entry
+        {
+            String m_aMessage = "";
+            String m_aTask = "";
+            int m_nBuildId = 0;
+
+            Entry( String aTask )
+            {
+                m_aTask = aTask;
+            }
+        }
+
+        HashMap<String,FilterEntry> m_aFilterEntries;
+        Entry m_aEntry = null;
+
+        Handler( HashMap<String,FilterEntry> aFilterEntries )
+        {
+            m_aFilterEntries = aFilterEntries;
+        }
+
+        public void characters(char[] aCh, int nStart, int nLength) throws SAXException {
+            if( m_aEntry != null )
+                m_aEntry.m_aMessage += new String(aCh, nStart, nLength);
+        }
+
+        public void startElement(String aUri, String aLocalName, String aQName, Attributes aAttributes) throws SAXException {
+            if( aQName.equals(FILTER_ENTRY) )
+            {
+               String aTaskId = aAttributes.getValue(TASK_ID);
+                if( aTaskId != null )
+                {
+                    m_aEntry = new Entry( aTaskId );
+                    String aBuildId = aAttributes.getValue(RESOLVED_IN);
+                    if( aBuildId != null && aBuildId.length() > 0)
+                        m_aEntry.m_nBuildId = Integer.valueOf(aBuildId);
+                }
+               
+            }
+        }
+
+        public void endElement(String aUri, String aLocalName, String aQName) throws SAXException {
+            if( aQName.equals(FILTER_ENTRY) )
+            {
+                if( m_aEntry != null )
+                {
+                    m_aFilterEntries.put( m_aEntry.m_aMessage, new FilterEntry(m_aEntry.m_aTask,m_aEntry.m_nBuildId) );
+                }
+            }
+        }
+
+    }
+    
+    /** Creates a new instance of ValidationErrorFilter */
+    public ValidationOOoTaskIdErrorFilter( File aFilterFile, PrintStream aOut ) throws ODFValidatorException {
+        m_aFilterEntries = new HashMap<String,FilterEntry>();
+        m_aTaskIdsReported = new HashSet<String>();
+        SAXParser aParser = null;
+        Logger aLogger = new Logger( aFilterFile.getAbsolutePath(), "", aOut, Logger.ERROR );
+        try
+        {
+            SAXParserFactory aParserFactory = SAXParserFactory.newInstance();
+            aParserFactory.setNamespaceAware(false);
+            aParser = aParserFactory.newSAXParser();
+
+            aParser.parse(aFilterFile, new Handler( m_aFilterEntries));
+        }
+        catch( javax.xml.parsers.ParserConfigurationException e )
+        {
+            throw new ODFValidatorException( e );
+        }
+        catch( org.xml.sax.SAXParseException e )
+        {
+            aLogger.logError( e );
+            throw new ODFValidatorException( e );
+        }
+        catch( org.xml.sax.SAXException e )
+        {
+            aLogger.logError( e.getMessage() );
+            throw new ODFValidatorException( e );
+        }
+        catch( java.io.IOException e )
+        {
+            throw new ODFValidatorException( e );
+        }
+
+
+    }
+    
+    public SAXParseException filterException( SAXParseException aExc )
+    {
+        if( m_nBuildId > 0 )
+        {
+            FilterEntry aEntry = m_aFilterEntries.get(aExc.getMessage());
+            if( aEntry != null && 
+                (aEntry.m_nBuildId == 0 || m_nBuildId <= aEntry.m_nBuildId) )
+            {
+                String aTaskId = aEntry.m_aTaskId;
+                if( !m_aTaskIdsReported.contains(aTaskId ))
+                {
+                    m_aTaskIdsReported.add( aTaskId );
+                    return new SAXParseException( "Issue " + aTaskId + " found.", aExc.getPublicId(), aExc.getSystemId(), aExc.getLineNumber(), aExc.getColumnNumber(), aExc );
+                }
+                else
+                    return null;
+            }
+        }
+        
+        return aExc;
+    }
+
+    public void startPackage( String aGenerator )
+    {
+        m_nBuildId = aGenerator.length() > 0 ? getBuildId( aGenerator) : 0;
+    }
+    
+    
+    public void startSubFile() {
+        m_aTaskIdsReported = new HashSet<String>();
+        // the build id is kept
+    }
+    
+    public void setGenerator( String aGenerator )
+    {
+        m_nBuildId = aGenerator.length() > 0 ? getBuildId( aGenerator) : 0;
+    }
+
+    public static int getBuildId( String aGenerator )
+    {
+        int nBuildId = 0;
+        int nPos = aGenerator.indexOf("OpenOffice.org_project/");
+        if( nPos>0 )
+        {
+            nPos = aGenerator.indexOf("Build-",nPos);
+            if( nPos > 0 )
+            {
+                int nStart = nPos+6;
+                nPos = aGenerator.indexOf("$",nStart);
+                nBuildId = Integer.valueOf(nPos > 0 ? aGenerator.substring(nStart,nPos) : aGenerator.substring(nStart));
+            }
+        }
+        
+        return nBuildId;
+    }
+    
+}

Added: incubator/odf/trunk/validator/src/odfvalidator/VersionHandler.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/src/odfvalidator/VersionHandler.java?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/src/odfvalidator/VersionHandler.java (added)
+++ incubator/odf/trunk/validator/src/odfvalidator/VersionHandler.java Mon Sep 19 05:30:38 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 odfvalidator;
+
+import org.xml.sax.Attributes;
+import org.xml.sax.SAXException;
+import org.xml.sax.helpers.DefaultHandler;
+
+public class VersionHandler extends DefaultHandler {
+
+    private static final String OFFICE_NAMESPACE_URI = "urn:oasis:names:tc:opendocument:xmlns:office:1.0";
+    private static final String DOCUMENT_META = "document-meta";
+    private static final String DOCUMENT_CONTENT = "document-content";
+    private static final String DOCUMENT_SETTINGS = "document-settings";
+    private static final String DOCUMENT_STYLES = "document-styles";
+    private static final String VERSION = "version";
+
+    @Override
+    public void startElement(String aUri, String aLocalName, String aQName, Attributes aAttributes) throws SAXException {
+        super.startElement(aUri, aLocalName, aQName, aAttributes);
+        
+        if( aUri.equals(OFFICE_NAMESPACE_URI) &&
+            (aLocalName.equalsIgnoreCase(DOCUMENT_META) ||
+             aLocalName.equalsIgnoreCase(DOCUMENT_CONTENT) || 
+             aLocalName.equalsIgnoreCase(DOCUMENT_SETTINGS) ||
+             aLocalName.equalsIgnoreCase(DOCUMENT_STYLES)) )
+        {
+            String aVersion = aAttributes.getValue(OFFICE_NAMESPACE_URI,VERSION);
+            throw new SAXVersionException(aVersion);
+        }
+    }
+
+}

Added: incubator/odf/trunk/validator/xslt/create_config.xsl
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/xslt/create_config.xsl?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/xslt/create_config.xsl (added)
+++ incubator/odf/trunk/validator/xslt/create_config.xsl Mon Sep 19 05:30:38 2011
@@ -0,0 +1,52 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+  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.
+
+-->
+
+<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
+  <xsl:output method="xml" doctype-system="http://java.sun.com/dtd/properties.dtd"/>
+
+  <xsl:param name="manifest-schema"/>
+  <xsl:param name="strict-schema"/>
+  <xsl:param name="schema"/>
+  <xsl:param name="dsig-schema"/>
+  <xsl:param name="mathml-schema"/>
+  <xsl:param name="mathml2-schema"/>
+  <xsl:param name="path"/>
+  <xsl:param name="filter"/>
+
+  
+  <!-- default: copy everything. -->
+  <xsl:template match="@*|node()">
+    <xsl:copy>
+      <xsl:apply-templates select="@*|node()"/>
+    </xsl:copy>
+  </xsl:template>
+  
+  <xsl:template match="entry[@key='manifest-schema']"><entry key="manifest-schema"><xsl:value-of select="$manifest-schema"/></entry></xsl:template>
+  <xsl:template match="entry[@key='strict-schema']"><entry key="strict-schema"><xsl:value-of select="$strict-schema"/></entry></xsl:template>
+  <xsl:template match="entry[@key='schema']"><entry key="schema"><xsl:value-of select="$schema"/></entry></xsl:template>
+  <xsl:template match="entry[@key='mathml-schema']"><entry key="mathml-schema"><xsl:value-of select="$mathml-schema"/></entry></xsl:template>
+  <xsl:template match="entry[@key='mathml2-schema']"><entry key="mathml2-schema"><xsl:value-of select="$mathml2-schema"/></entry></xsl:template>
+  <xsl:template match="entry[@key='dsig-schema']"><entry key="dsig-schema"><xsl:value-of select="$dsig-schema"/></entry></xsl:template>
+  <xsl:template match="entry[@key='filter']"><entry key="filter"><xsl:value-of select="$filter"/></entry></xsl:template>
+  <xsl:template match="entry[@key='path1']"><entry key="path1"><xsl:value-of select="$path"/></entry></xsl:template>
+</xsl:stylesheet>

Added: incubator/odf/trunk/validator/xslt/fix_rng_for_msv.xsl
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/xslt/fix_rng_for_msv.xsl?rev=1172430&view=auto
==============================================================================
--- incubator/odf/trunk/validator/xslt/fix_rng_for_msv.xsl (added)
+++ incubator/odf/trunk/validator/xslt/fix_rng_for_msv.xsl Mon Sep 19 05:30:38 2011
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<!--
+
+  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.
+
+-->
+
+<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
+    xmlns:rng="http://relaxng.org/ns/structure/1.0"
+    exclude-result-prefixes="rng"
+    >
+    <xsl:output method="xml"/>
+
+    <!-- default: copy everything. -->
+    <xsl:template match="@*|node()">
+        <xsl:copy>
+            <xsl:apply-templates select="@*|node()"/>
+        </xsl:copy>
+    </xsl:template>
+   
+    <xsl:template match="rng:element/rng:ref[@name='string']">
+        <text/>
+    </xsl:template>
+    
+    <xsl:template match="rng:element/rng:choice/rng:group/rng:ref[@name='string']">
+        <text/>
+    </xsl:template>
+ 
+</xsl:stylesheet>



Mime
View raw message