-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.xml
144 lines (120 loc) · 7.02 KB
/
build.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?xml version="1.0" encoding="UTF-8"?><!--
This file is part of the Spelling and Grammar Checker project.
See the accompanying LICENSE file for applicable licenses.
--><project name="com.here.validate.svrl.text-rules">
<!--
Setting up sauto-correction. Sets up an ANT property to add meta data in the
the XSL processing.
-->
<target name="auto-correct-pre-process" depends="text-rules-pre-process">
<property name="text-rules.auto-correct" value="true"/>
</target>
<!--
Runs a simple find and replace regex over errors that have been discovered.
-->
<target name="auto-correct-post-process">
<tempfile property="auto-correct.xml" suffix=".xml" deleteonexit="true"/>
<xslt basedir="${svrl.dir}" style="${com.here.validate.svrl.text-rules.dir}/xsl/auto-correct-output.xsl" in="${output.dir}/${com.here.validate.svrl.filename.root}.svrl" out="${auto-correct.xml}" classpathref="dost.class.path">
</xslt>
<ant antfile="${auto-correct.xml}">
<property name="dir" value="${args.input.dir}"/>
</ant>
</target>
<!--
Setting up schematron processing for spell-checking.
Sets up ANT variable overrides for the spelling and grammar-checker
-->
<target name="text-rules-pre-process" depends="svrl-pre-process, strip-doctype">
<dirname property="com.here.validate.svrl.text-rules.dir" file="${ant.file.com.here.validate.svrl.text-rules}"/>
<!--
Load a set of mistakes and corrections from a set of dictionary files.
The plugin provides en, fr and de only
-->
<property name="text-rules.dictionary.dir" location="${com.here.validate.svrl.text-rules.dir}/cfg/dictionary/${default.language}"/>
<tempfile property="grammar.txt" suffix=".txt" deleteonexit="true"/>
<tempfile property="duplicates.txt" suffix=".txt" deleteonexit="true"/>
<tempfile property="spelling.txt" suffix=".txt" deleteonexit="true"/>
<tempfile property="punctuation.txt" suffix=".txt" deleteonexit="true"/>
<xslt style="${com.here.validate.svrl.text-rules.dir}/xsl/dictionary2regex.xsl" in="${text-rules.dictionary.dir}/grammar.xml" out="${grammar.txt}" failOnError="false" classpathref="dost.class.path">
</xslt>
<xslt style="${com.here.validate.svrl.text-rules.dir}/xsl/dictionary2regex.xsl" in="${text-rules.dictionary.dir}/duplicates.xml" out="${duplicates.txt}" failOnError="false" classpathref="dost.class.path">
</xslt>
<xslt style="${com.here.validate.svrl.text-rules.dir}/xsl/dictionary2regex.xsl" in="${text-rules.dictionary.dir}/spelling.xml" out="${spelling.txt}" failOnError="false" classpathref="dost.class.path">
</xslt>
<xslt style="${com.here.validate.svrl.text-rules.dir}/xsl/dictionary2regex.xsl" in="${text-rules.dictionary.dir}/punctuation.xml" out="${punctuation.txt}" failOnError="false" classpathref="dost.class.path">
<param name="PREFIX" expression="("/>
<param name="POSTFIX" expression=")"/>
</xslt>
<!--
Define a regex for each type of error checked, this avoids making the
same request for each *.dita file checked.
-->
<loadfile property="grammar.regex" srcfile="${grammar.txt}" failonerror="false"/>
<loadfile property="duplicates.regex" srcfile="${duplicates.txt}" failonerror="false"/>
<loadfile property="spelling.regex" srcfile="${spelling.txt}" failonerror="false"/>
<loadfile property="punctuation.regex" srcfile="${punctuation.txt}" failonerror="false"/>
</target>
<!--
Ant target to allow direct invocation of the spelling and grammar checker transforms, in case
a custom plug-in wishes to integrate this as a processing step.
-->
<target name="text-rules">
<echo level="info" message="Proofreading and spell-checking document"/>
<path id="text-rules.xml.path">
<pathelement location="${text-rules.dictionary.dir}"/>
</path>
<pathconvert targetos="unix" property="text-rules.xml.path.unix" refid="text-rules.xml.path">
<map from="c:" to=""/>
</pathconvert>
<!-- Decide the severity of each type of error -->
<get-validation-rulesets file="${com.here.validate.svrl.text-rules.dir}/cfg/ruleset/${args.validate.ruleset}.xml" fatal="text-rules.fatal" error="text-rules.error" warning="text-rules.warning"/>
<!--
Apply the XSLT defined over the root ditamap This create SVRL files from the *.ditamap and fires the associated spelling and grammar checker validator ruleset.
-->
<xslt extension=".svrl" style="${com.here.validate.svrl.text-rules.dir}/xsl/dita2svrl.xsl" destdir="${com.here.validate.svrl.tmp.dir}/svrl/text-rules" useImplicitFileset="false" failOnError="false" classpathref="dost.class.path">
<xmlcatalog refid="dita.catalog"/>
<factory name="net.sf.saxon.TransformerFactoryImpl">
<!--
Setting several options of Saxon XSLT engine to enable some additional functionality,
see for more details:
http://www.saxonica.com/html/documentation/configuration/config-features.html
-->
<attribute name="http://saxon.sf.net/feature/allow-external-functions" value="true"/>
<!-- Enable keeping track of line numbers whilst transforming -->
<attribute name="http://saxon.sf.net/feature/linenumbering" value="true"/>
<attribute name="http://saxon.sf.net/feature/sourceParserClass" value="org.apache.xml.resolver.tools.ResolvingXMLReader"/>
<!-- Disable DTD validation whilst transforming -->
<attribute name="http://saxon.sf.net/feature/validation" value="false"/>
</factory>
<param name="SOURCE" expression="${com.here.validate.svrl.tmp.dir}/dita"/>
<param name="DICTIONARY_DIR" expression="${text-rules.xml.path.unix}"/>
<param name="GRAMMAR_REGEX" expression="${grammar.regex}" if="grammar.regex"/>
<param name="DUPLICATES_REGEX" expression="${duplicates.regex}" if="duplicates.regex"/>
<param name="SPELLING_REGEX" expression="${spelling.regex}" if="spelling.regex"/>
<param name="PUNCTUATION_REGEX" expression="${punctuation.regex}" if="punctuation.regex"/>
<param name="DEFAULTLANG" expression="${document.language}" if="document.language"/>
<param name="FATAL_RULESET" expression="${text-rules.fatal}"/>
<param name="ERROR_RULESET" expression="${text-rules.error}"/>
<param name="WARNING_RULESET" expression="${text-rules.warning}"/>
<param name="AUTO_CORRECT" expression="${text-rules.auto-correct}" if="text-rules.auto-correct"/>
<param name="BLACKLIST" expression="${args.validate.blacklist}"/>
<param name="CHECK_CASE" expression="${args.validate.check.case}"/>
<fileset dir="${com.here.validate.svrl.tmp.dir}/dita">
<include name="**/*.dita"/>
</fileset>
</xslt>
</target>
<!--
ANT target executed to create an SVRL file holding a list of spelling errors
-->
<target name="dita2text-rules" depends="text-rules-pre-process, text-rules, svrl-merge"/>
<!--
ANT target executed when the echo transtype is invoked. This echoes the spelling
mistakes to the standard output and fails the build if errors have been found.
-->
<target name="dita2text-rules-echo" depends="dita2text-rules, svrl-filter"/>
<!--
ANT target executed to remove spelling errors from a document.
-->
<target name="dita2auto-correct" depends="auto-correct-pre-process, text-rules, svrl-merge, auto-correct-post-process"/>
</project>