incubator-odf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From devin...@apache.org
Subject svn commit: r1172464 - in /incubator/odf/trunk/validator: ant.properties build.xml schema.user.properties xslt/extract_schema.xsl
Date Mon, 19 Sep 2011 05:40:27 GMT
Author: devinhan
Date: Mon Sep 19 05:40:27 2011
New Revision: 1172464

URL: http://svn.apache.org/viewvc?rev=1172464&view=rev
Log:
changeset:   33:a646c5600c79
user:        michael.brauer
date:        Fri Mar 25 12:22:59 2011 +0100
- Optionally extract ODF 1.0 and 1.1 schemas from specification document

Added:
    incubator/odf/trunk/validator/ant.properties
    incubator/odf/trunk/validator/xslt/extract_schema.xsl
Modified:
    incubator/odf/trunk/validator/build.xml
    incubator/odf/trunk/validator/schema.user.properties

Added: incubator/odf/trunk/validator/ant.properties
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/ant.properties?rev=1172464&view=auto
==============================================================================
--- incubator/odf/trunk/validator/ant.properties (added)
+++ incubator/odf/trunk/validator/ant.properties Mon Sep 19 05:40:27 2011
@@ -0,0 +1,8 @@
+# The following properties have to be set only if the ODF 1.0 and 1.1 schema
+# shall be extracted from the specification documents.
+
+# location of the odftoolkit.org odfxsltrunner project
+reference.odfxsltrunner.jar=../conformancetools~odf-xslt-runner-src/dist/odfxsltrunner.jar
+
+# location of the odftoolkit.org odfxsltrunner task project
+reference.odfxsltrunner-task.jar=../conformancetools~odf-xslt-runner-task-src/dist/odfxsltrunnertask.jar

Modified: incubator/odf/trunk/validator/build.xml
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/build.xml?rev=1172464&r1=1172463&r2=1172464&view=diff
==============================================================================
--- incubator/odf/trunk/validator/build.xml (original)
+++ incubator/odf/trunk/validator/build.xml Mon Sep 19 05:40:27 2011
@@ -89,9 +89,11 @@
 
     <property file="schema.properties"/>
 
+    <property name="opendocument.v10.spec" value="OpenDocument-v1.0${opendocument.v10.schema.state}.odt"/>
     <property name="opendocument.v10.schema" value="OpenDocument-schema-v1.0${opendocument.v10.schema.state}.rng"/>
     <property name="opendocument.v10.schema.strict" value="OpenDocument-strict-schema-v1.0${opendocument.v10.schema.state}.rng"/>
     <property name="opendocument.v10.schema.manifest" value="OpenDocument-manifest-schema-v1.0${opendocument.v10.schema.state}.rng"/>
+    <property name="opendocument.v11.spec" value="OpenDocument-v1.1${opendocument.v11.schema.state}.odt"/>
     <property name="opendocument.v11.schema" value="OpenDocument-schema-v1.1${opendocument.v11.schema.state}.rng"/>
     <property name="opendocument.v11.schema.strict" value="OpenDocument-strict-schema-v1.1${opendocument.v11.schema.state}.rng"/>
     <property name="opendocument.v11.schema.manifest" value="OpenDocument-manifest-schema-v1.1${opendocument.v11.schema.state}.rng"/>
@@ -106,11 +108,21 @@
                 <isset property="opendocument.v10.schema.dir"/>
             </not>
         </condition>
+        <condition property="opendocument.v10.schema.extract" value="${user.opendocument.v10.schema.extract}">
+            <not>
+                <isset property="opendocument.v10.schema.extract"/>
+            </not>
+        </condition>
         <condition property="opendocument.v11.schema.dir" value="${user.opendocument.v11.schema.dir}">
             <not>
                 <isset property="opendocument.v11.schema.dir"/>
             </not>
         </condition>
+        <condition property="opendocument.v11.schema.extract" value="${user.opendocument.v11.schema.extract}">
+            <not>
+                <isset property="opendocument.v11.schema.extract"/>
+            </not>
+        </condition>
         <condition property="opendocument.v12.schema.dir" value="${user.opendocument.v12.schema.dir}">
             <not>
                 <isset property="opendocument.v12.schema.dir"/>
@@ -143,22 +155,64 @@
         </condition>
     </target>
 
-    <target name="-pre-jar" depends="init,-copy-v10-schema,-copy-v11-schema,-copy-v12-schema,-copy-mathml-schema,-copy-mathml2-schema,-create-v10-validator-config,-create-v11-validator-config,-create-v12-validator-config"/>
+    <target name="-pre-jar" depends="init,-copy-v10-schema,-extract-v10-schema,-copy-v11-schema,-extract-v11-schema,-copy-v12-schema,-copy-mathml-schema,-copy-mathml2-schema,-create-v10-validator-config,-create-v11-validator-config,-create-v12-validator-config"/>
        
-    <target name="-copy-v10-schema" depends="init">
+    <target name="-copy-v10-schema" depends="init" unless="opendocument.v10.schema.extract">
         <copy todir="${build.classes.dir}/schema/odf10">
             <fileset dir="${opendocument.v10.schema.dir}"
                 includes="${opendocument.v10.schema},${opendocument.v10.schema.strict},${opendocument.v10.schema.manifest}"/>
         </copy>
     </target>
 
-    <target name="-copy-v11-schema" depends="init">
+    <target name="-extract-v10-schema" depends="init" if="opendocument.v10.schema.extract">
+        <property file="ant.properties"/>
+        <taskdef name="odfxslt" classname="org.odftoolkit.odfxsltrunnertask.ODFXSLTRunnerTask"
classpath="${reference.odfxsltrunner-task.jar}:${reference.odfxsltrunner.jar}"/>
+        <odfxslt in="${opendocument.v10.schema.dir}/${opendocument.v10.spec}"
+                 outfile="${build.classes.dir}/schema/odf10/${opendocument.v10.schema}"
+                 style="xslt/extract_schema.xsl">
+            <param name="mode" expression="schema"/>
+        </odfxslt>
+        <odfxslt in="${opendocument.v10.schema.dir}/${opendocument.v10.spec}"
+                 outfile="${build.classes.dir}/schema/odf10/${opendocument.v10.schema.strict}"
+                 style="xslt/extract_schema.xsl">
+            <param name="mode" expression="strict-schema"/>
+        </odfxslt>
+        <odfxslt in="${opendocument.v10.schema.dir}/${opendocument.v10.spec}"
+                 outfile="${build.classes.dir}/schema/odf10/${opendocument.v10.schema.manifest}"
+                 style="xslt/extract_schema.xsl">
+            <param name="mode" expression="manifest-schema"/>
+        </odfxslt>
+        <fixcrlf srcdir="${build.classes.dir}/schema/odf10" eol="lf"/>
+    </target>
+
+    <target name="-copy-v11-schema" depends="init" unless="opendocument.v11.schema.extract">
         <copy todir="${build.classes.dir}/schema/odf11">
             <fileset dir="${opendocument.v11.schema.dir}"
                 includes="${opendocument.v11.schema},${opendocument.v11.schema.strict},${opendocument.v11.schema.manifest}"/>
         </copy>
     </target>
 
+    <target name="-extract-v11-schema" depends="init" if="opendocument.v11.schema.extract">
+        <property file="ant.properties"/>
+        <taskdef name="odfxslt" classname="org.odftoolkit.odfxsltrunnertask.ODFXSLTRunnerTask"
classpath="${reference.odfxsltrunner-task.jar}:${reference.odfxsltrunner.jar}"/>
+        <odfxslt in="${opendocument.v11.schema.dir}/${opendocument.v11.spec}"
+                 outfile="${build.classes.dir}/schema/odf11/${opendocument.v11.schema}"
+                 style="xslt/extract_schema.xsl">
+            <param name="mode" expression="schema"/>
+        </odfxslt>
+        <odfxslt in="${opendocument.v11.schema.dir}/${opendocument.v11.spec}"
+                 outfile="${build.classes.dir}/schema/odf11/${opendocument.v11.schema.strict}"
+                 style="xslt/extract_schema.xsl">
+            <param name="mode" expression="strict-schema"/>
+        </odfxslt>
+        <odfxslt in="${opendocument.v11.schema.dir}/${opendocument.v11.spec}"
+                 outfile="${build.classes.dir}/schema/odf11/${opendocument.v11.schema.manifest}"
+                 style="xslt/extract_schema.xsl">
+            <param name="mode" expression="manifest-schema"/>
+        </odfxslt>
+        <fixcrlf srcdir="${build.classes.dir}/schema/odf11" eol="lf"/>
+    </target>
+
     <target name="-copy-v12-schema" depends="init">
         <copy todir="${build.classes.dir}/schema/odf12">
             <fileset dir="${opendocument.v12.schema.dir}" 

Modified: incubator/odf/trunk/validator/schema.user.properties
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/schema.user.properties?rev=1172464&r1=1172463&r2=1172464&view=diff
==============================================================================
--- incubator/odf/trunk/validator/schema.user.properties (original)
+++ incubator/odf/trunk/validator/schema.user.properties Mon Sep 19 05:40:27 2011
@@ -1,14 +1,20 @@
 #Set these properties either in this file, or in the nbproject/private/private.properties
file.
 
-# Directory where the OpenDocument v1.0 schemas are stored
+# Directory where the OpenDocument v1.0 schemas or specification are stored
 opendocument.v10.schema.dir=
 
-# Directory where the OpenDocument v1.1 schemas are stored
+# Directory where the OpenDocument v1.1 schemas or specification are stored
 opendocument.v11.schema.dir=
 
-# Directory where the OpenDocument v1.1 schemas are stored
+# Directory where the OpenDocument v1.2 schemas are stored
 opendocument.v12.schema.dir=
 
+# Extract OpenDocument v1.0 schemas from specification?
+opendocument.v10.schema.extract=
+
+# Extract OpenDocument v1.1 schemas from specification?
+opendocument.v11.schema.extract=
+
 # Directory where the MathML 1.01 DTD is stored
 mathml.schema.dir=
 

Added: incubator/odf/trunk/validator/xslt/extract_schema.xsl
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/xslt/extract_schema.xsl?rev=1172464&view=auto
==============================================================================
--- incubator/odf/trunk/validator/xslt/extract_schema.xsl (added)
+++ incubator/odf/trunk/validator/xslt/extract_schema.xsl Mon Sep 19 05:40:27 2011
@@ -0,0 +1,168 @@
+<?xml version="1.0" encoding="utf-8"?>
+<!--
+
+  DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
+
+  Copyright 2008, 2010 Oracle and/or its affiliates. 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.
+
+-->
+
+<!-- This stylesheet extracts the ODF schemas from the ODF v1.0 and v1.1 -->
+<!-- specification.                                                      -->
+<xsl:stylesheet version="1.0"
+                xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
+                xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" 
+                xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0"
+                xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0">
+    
+    <xsl:output method="text"/>
+    
+    <!-- Supported mode parameter values are: -->
+    <!-- 'schema': Extracts the schema -->
+    <!-- 'strict-schema': Extracts the strict schema defined in appendix A -->
+    <!-- 'manifest-schema': Extracts the manifest schema -->
+    <xsl:param name="mode" select="'schema'"/>
+       
+    <!-- map mode paramater to style names -->
+    <!-- which paragraph styles do we wish to extract? -->
+    <xsl:param name="style">
+        <xsl:choose>
+            <xsl:when test="$mode='strict-schema'">
+                <xsl:value-of select="'RelaxNG_20_Strict'"/>
+            </xsl:when>
+            <xsl:when test="$mode='manifest-schema'">
+                <xsl:value-of select="'RelaxNG_20_Manifest'"/>
+            </xsl:when>
+            <xsl:when test="$mode='dsig-schema'">
+                <xsl:value-of select="'RelaxNG_20_DSig'"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="'RelaxNG'"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>    
+    <xsl:param name="style2">
+        <xsl:choose>
+            <xsl:when test="$mode='strict-schema'">
+                <xsl:value-of select="'Changed_20_Relax_20_NG_20_Strict'"/>
+            </xsl:when>            
+            <xsl:when test="$mode='manifest-schema'">
+                <xsl:value-of select="'Changed_20_Relax_20_NG_20_Manifest'"/>
+            </xsl:when>            
+            <xsl:when test="$mode='dsig-schema'">
+                <xsl:value-of select="'Changed_20_Relax_20_NG_20_DSig'"/>
+            </xsl:when>            
+            <xsl:otherwise>
+                <xsl:value-of select="'Changed_20_Relax_20_NG'"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>
+    <xsl:param name="style3">
+        <xsl:choose>
+            <xsl:when test="$mode='strict-schema'">
+                <xsl:value-of select="'RelaxNG_20_Strict_Linenumber_20_Correction'"/>
+            </xsl:when>
+            <xsl:when test="$mode='manifest-schema'">
+                <xsl:value-of select="'RelaxNG_20_Manifest_Linenumber_20_Correction'"/>
+            </xsl:when>
+            <xsl:when test="$mode='dsig-schema'">
+                <xsl:value-of select="'RelaxNG_20_DSig_20_Linenumber_20_Correction'"/>
+            </xsl:when>               
+            <xsl:otherwise>
+                <xsl:value-of select="'RelaxNG_20_Linenumber_20_Correction'"/>
+            </xsl:otherwise>
+        </xsl:choose>	  
+    </xsl:param>
+    <xsl:param name="style4">
+        <xsl:choose>
+            <xsl:when test="$mode='strict-schema'">
+                <xsl:value-of select="'RelaxNG_20_Strict_20_Start'"/>
+            </xsl:when>
+            <xsl:when test="$mode='manifest-schema'">
+                <xsl:value-of select="'RelaxNG_20_Manifest_20_Start'"/>
+            </xsl:when>
+            <xsl:when test="$mode='dsig-schema'">
+                <xsl:value-of select="'RelaxNG_20_DSig_20_Start'"/>
+            </xsl:when>
+            <xsl:otherwise>
+                <xsl:value-of select="'RelaxNG_20_Start'"/>
+            </xsl:otherwise>
+        </xsl:choose>
+    </xsl:param>    
+
+    <!-- define 'styles' key. It selects all style:style element with a certain name -->
+    <xsl:key name="styles"
+             match="style:style"
+             use="@style:name" />
+
+    <xsl:template match="office:document-content">
+        <xsl:apply-templates select="office:body/office:text//text:p"/>
+    </xsl:template>
+
+    <!-- analyze paragraphs -->
+    <xsl:template match="text:p">
+        
+        <!-- determine all parent styles of this paragraph; use key 'parents' -->
+        <xsl:variable name="parent-styles"
+                      select="@text:style-name |
+                      key('styles',@text:style-name)/@style:parent-style-name"/>
+        
+        <!-- if schema parent style is found, generate output -->
+        <xsl:if test="$parent-styles = $style or $parent-styles = $style2 or $parent-styles
= $style3 or $parent-styles = $style4">
+            <xsl:apply-templates mode="output"/>
+            <xsl:text>
+</xsl:text>
+        </xsl:if>
+    </xsl:template>
+
+    <!-- default: don't output anything -->
+    <xsl:template match="node()|@*"/>
+
+    <!-- generate output: just copy all text -->
+    <xsl:template mode="output" match="*">
+        <xsl:apply-templates mode="output"/>
+    </xsl:template>
+        
+    <xsl:template mode="output" match="text()">
+        <xsl:copy/>
+    </xsl:template>
+    
+    <!-- white space handling: <text:s>, <text:tab> elements  -->
+    <xsl:template mode="output" match="text:tab">
+        <xsl:text>    </xsl:text>
+    </xsl:template>
+    
+    <xsl:template mode="output" match="text:s">
+        <xsl:call-template name="repeat">
+            <xsl:with-param name="count" select="@text:c"/>
+            <xsl:with-param name="string" select="' '"/>
+        </xsl:call-template>
+    </xsl:template>
+    
+    <xsl:template name="repeat">
+        <xsl:param name="count"/>
+        <xsl:param name="string"/>
+        <xsl:if test="$count > 0">
+            <xsl:value-of select="$string"/>
+            <xsl:call-template name="repeat">
+                <xsl:with-param name="count" select="$count - 1"/>
+                <xsl:with-param name="string" select="$string"/>
+            </xsl:call-template>
+        </xsl:if>
+    </xsl:template>
+    
+</xsl:stylesheet>



Mime
View raw message