Author: devinhan
Date: Mon Sep 19 05:40:44 2011
New Revision: 1172465
URL: http://svn.apache.org/viewvc?rev=1172465&view=rev
Log:
changeset: 34:8805ccf2d478
user: michael.brauer
date: Fri Mar 25 13:16:07 2011 +0100
- Optimized schema extraction
- Adapted tests to ODFDOM 0.8.7
Modified:
incubator/odf/trunk/validator/build.xml
incubator/odf/trunk/validator/test/org/odftoolkit/odfvalidator/InvalidPackageTest.java
incubator/odf/trunk/validator/xslt/extract_schema.xsl
Modified: incubator/odf/trunk/validator/build.xml
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/build.xml?rev=1172465&r1=1172464&r2=1172465&view=diff
==============================================================================
--- incubator/odf/trunk/validator/build.xml (original)
+++ incubator/odf/trunk/validator/build.xml Mon Sep 19 05:40:44 2011
@@ -167,22 +167,23 @@
<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}"/>
+ <property name="v10.target.dir" value="${build.classes.dir}/schema/odf10"/>
<odfxslt in="${opendocument.v10.schema.dir}/${opendocument.v10.spec}"
- outfile="${build.classes.dir}/schema/odf10/${opendocument.v10.schema}"
+ outfile="${v10.target.dir}/${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}"
+ outfile="${v10.target.dir}/${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}"
+ outfile="${v10.target.dir}/${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"/>
+ <fixcrlf srcdir="${v10.target.dir}" eol="lf"/>
</target>
<target name="-copy-v11-schema" depends="init" unless="opendocument.v11.schema.extract">
@@ -195,22 +196,23 @@
<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}"/>
+ <property name="v11.target.dir" value="${build.classes.dir}/schema/odf11"/>
<odfxslt in="${opendocument.v11.schema.dir}/${opendocument.v11.spec}"
- outfile="${build.classes.dir}/schema/odf11/${opendocument.v11.schema}"
+ outfile="${v11.target.dir}/${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}"
+ outfile="${v11.target.dir}/${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}"
+ outfile="${v11.target.dir}/${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"/>
+ <fixcrlf srcdir="${v11.target.dir}" eol="lf"/>
</target>
<target name="-copy-v12-schema" depends="init">
Modified: incubator/odf/trunk/validator/test/org/odftoolkit/odfvalidator/InvalidPackageTest.java
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/test/org/odftoolkit/odfvalidator/InvalidPackageTest.java?rev=1172465&r1=1172464&r2=1172465&view=diff
==============================================================================
--- incubator/odf/trunk/validator/test/org/odftoolkit/odfvalidator/InvalidPackageTest.java
(original)
+++ incubator/odf/trunk/validator/test/org/odftoolkit/odfvalidator/InvalidPackageTest.java
Mon Sep 19 05:40:44 2011
@@ -60,7 +60,7 @@ public class InvalidPackageTest extends
Assert.assertTrue(output.contains("testInvalidPkg1.odt/mimetype:Error:The file 'mimetype'
shall not be compressed"));
Assert.assertTrue(output.contains("testInvalidPkg1.odt/mimetype:Error:There shall
be no extra field for the 'mimetype' file"));
Assert.assertTrue(output.contains("testInvalidPkg1.odt/META-INF/manifest.xml:Error:The
file 'Configurations2/accelerator/current.xml' shall not be listed in the 'META-INF/manifest.xml'
file as it does not exist in the ODF package"));
- Assert.assertTrue(output.contains("testInvalidPkg1.odt:Info:9 errors, 11 warnings"));
+ Assert.assertTrue(output.contains("testInvalidPkg1.odt:Info:10 errors, 11 warnings"));
}
@Test
@@ -92,7 +92,7 @@ public class InvalidPackageTest extends
Assert.assertTrue(output.contains("testInvalidPkg2.odt/mimetype:Warning:The ODF package
'testInvalidPkg2.odt' contains no 'mimetype' file"));
Assert.assertTrue(output.contains("testInvalidPkg2.odt/META-INF/manifest.xml:Error:The
file 'Configurations2/accelerator/current.xml' shall not be listed in the 'META-INF/manifest.xml'
file as it does not exist in the ODF package"));
Assert.assertTrue(output.contains("testInvalidPkg2.odt/META-INF/manifest.xml:Warning:The
file 'not_in_manifest' shall be listed in the 'META-INF/manifest.xml' file as it exists in
the ODF package"));
- Assert.assertTrue(output.contains("testInvalidPkg2.odt:Info:6 errors, 12 warnings"));
+ Assert.assertTrue(output.contains("testInvalidPkg2.odt:Info:7 errors, 12 warnings"));
}
@Test
Modified: incubator/odf/trunk/validator/xslt/extract_schema.xsl
URL: http://svn.apache.org/viewvc/incubator/odf/trunk/validator/xslt/extract_schema.xsl?rev=1172465&r1=1172464&r2=1172465&view=diff
==============================================================================
--- incubator/odf/trunk/validator/xslt/extract_schema.xsl (original)
+++ incubator/odf/trunk/validator/xslt/extract_schema.xsl Mon Sep 19 05:40:44 2011
@@ -3,7 +3,7 @@
DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER
- Copyright 2008, 2010 Oracle and/or its affiliates. All rights reserved.
+ Copyright 2011 Oracle and/or its affiliates. All rights reserved.
Use is subject to license terms.
@@ -37,9 +37,9 @@
<!-- 'manifest-schema': Extracts the manifest schema -->
<xsl:param name="mode" select="'schema'"/>
- <!-- map mode paramater to style names -->
+ <!-- map mode parameter to style names -->
<!-- which paragraph styles do we wish to extract? -->
- <xsl:param name="style">
+ <xsl:variable name="extract-style-name">
<xsl:choose>
<xsl:when test="$mode='strict-schema'">
<xsl:value-of select="'RelaxNG_20_Strict'"/>
@@ -47,82 +47,34 @@
<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>
+ </xsl:variable>
<!-- define 'styles' key. It selects all style:style element with a certain name -->
<xsl:key name="styles"
match="style:style"
use="@style:name" />
+ <!-- Look only at paragraphs -->
<xsl:template match="office:document-content">
<xsl:apply-templates select="office:body/office:text//text:p"/>
</xsl:template>
- <!-- analyze paragraphs -->
+ <!-- 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"/>
-
+ <xsl:variable name="content-style-names" select="@text:style-name|key('styles',@text:style-name)/@style:parent-style-name"/>
+ <xsl:variable name="styles-style-names">
+ <xsl:for-each select="document('styles.xml',.)">
+ <xsl:value-of select="key('styles',$content-style-names)/@style:parent-style-name"/>
+ </xsl:for-each>
+ </xsl:variable>
+
<!-- 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:if test="$content-style-names = $extract-style-name or $styles-style-names
= $extract-style-name">
<xsl:apply-templates mode="output"/>
<xsl:text>
</xsl:text>
@@ -165,4 +117,4 @@
</xsl:if>
</xsl:template>
-</xsl:stylesheet>
+</xsl:stylesheet>
\ No newline at end of file
|